异步命令行应用程序构建器。
项目描述
precept
异步应用程序框架。
安装
使用pip安装: $ pip install precept
用法
基本
from precept import Precept, Command, Argument
class MyCli(Precept):
"""
The name of the application will be the spinal-case version of
the name of the class.
Class docstring is added as cli description.
"""
@Command(Argument('argument', type=str))
async def my_command(self, argument):
print(argument)
def cli():
MyCli().start()
if __name__ == '__main__':
cli()
本地测试
- 在
setup.py
中将entry_points.console_script
设置为my-cli = my_package.my_cli:cli
- 本地安装:
$ pip install -e .
- 然后调用:
$ my-cli my-command hello
-> 打印hello