用于在函数和类中轻松定义脚本参数的装饰器和包装器。只是定义函数的参数。
ArgParseInator的Python项目详细描述
argparseinator
Argparseinator是一个愚蠢但有用的东西,它允许您轻松地添加 argparse的参数和选项直接在函数中指向脚本 以及使用一些装饰器的类。
安装
pip安装argparseinator
快速示例(sayciao.py模块)
""" Say ciao script. """__version__="1.2.3"fromargparseinatorimportArgParseInator,arg@arg()defsayciao(name):""" I will say ciao. """print"Ciao",nameif__name__=='__main__':ArgParseInator().check_command()
呼叫:
$ python sayciao.py --help
将输出:
usage: sayciao.py [-h][-v] name Say ciao script. I will say ciao. positional arguments: name optional arguments: -h, --help show this help message and exit -v, --version show program's version number and exit
呼叫:
$ python sayciao.py --version
将输出:
sayciao.py 1.2.3
呼叫:
$ python sayciao.py luca
将输出:
Ciao luca