创建cli应用程序的简单工具
arg的Python项目详细描述
argy
argy是一个使用python创建cli程序的简单工具,它试图消除标准库附带的所有模糊。
用法
import argy @argy def add_numbers(x, y, subtract=False): """Adder of numbers Just adds two numbers, nothing really special about it :param x: The first number :type x: int :param y: The second number :type y: int :param subtract: Should we subtract instead? :type subtract: bool """ if not subtract: return x + y else: return x - y
这将创建带有预期参数的cli程序,另请参见example.py
$ python example.py -h usage: example.py [-h] [--subtract SUBTRACT] x y positional arguments: x The first number y The second number optional arguments: -h, --help show this help message and exit --subtract SUBTRACT Should we subtract instead?
贡献
欢迎投稿!