我一直在尝试使用docopt来创建一个简单的CLI,但由于某种原因,我的默认参数没有出现.下面是我的测试代码.我正在使用docopt.pygithub存储库的最新版本.
"""
Usage: scrappy <path> ... [options]
-a --auto Automatically scrape and rename without user interaction.
-l --lang Specify language code [default: en].
--scan-individual Evaluate series information individually for each file.
-c --cfg User alternate config file [default: ../scrappy.conf]
-t --test Test run. Do not modify files.
-v --verbose Print verbose output
"""
from docopt import docopt
arguments = docopt(__doc__, version='0.1.0 alpha')
print arguments # DEBUG
Run Code Online (Sandbox Code Playgroud)
这是我跑步时的输出 $ scrappy/scrappy.py first_path_parameter second/path/parameter
{'--auto': None,
'--cfg': None,
'--lang': None,
'--scan-individual': …Run Code Online (Sandbox Code Playgroud)