pyqa使编写生成配置的会话脚本变得容易
pyqa的Python项目详细描述
pyqa使编写基于终端的工具变得更容易,这些工具要求用户 一堆问题,然后根据 答案。
用法
有关一些工作示例,请参见/演示。
pyqa提供单一的函数“ask”。它需要一系列的问题 以特定格式给出。以下是yaml中的描述,但是您 只要输出匹配,就可以自由使用任何其他标记语言:
--- id: project_name # id to use at the template q: Could you please give the project name? # question shown to the user --- id: license q: Please pick a license for your project? choices: # if choices field is used, the user will see these as numbered choice - BSD - GPL - MIT --- id: use_fizzler q: Are you sure you want to use fizzler? type: boolean -- this will accept either true or false answer and emits True/False
注意,关键字“yes”和“no”似乎通过 亚姆。如果你需要在选择中使用这些,记得使用显式 形式(即“是”而不是“是”)。
用户回答完“ask”后,将在 格式如下:
{'project_name': 'myproject', 'license': 'BSD', 'use_fizzler': True}
此格式碰巧与 pystache(python版本的 mustache)而且毫无疑问 模板引擎。只需将数据传递到您喜爱的引擎render 把文件输出到某个地方。喂!
许可证
pyqa在mit许可下可用。有关详细信息,请参见许可证。