【发布时间】:2015-06-01 13:36:22
【问题描述】:
我将 python 应用程序用作命令行工具,功能 docopt library。使用该库很容易实现命令。 但是,目前我找不到完成以下要求的方法:
文档字符串是:
"""
aTXT tool
Usage:
aTXT <source>... [--ext <ext>...]
Options:
--ext message
"""
从shell,我想写这样的东西:
atxt a b c --ext e f g
docopt 输出的结果字典如下:
{'--ext': True,
'<ext>': [],
'<source>': ['a', 'b', 'c', 'e', 'f']}
但是,我需要具备以下条件:
{'--ext': True,
'<ext>': ['e', 'f', 'g'],
'<source>': ['a', 'b', 'c']}
我该如何进行?
【问题讨论】:
标签: python command-line-interface command-line-arguments docopt