Docopt loves to write lots of documentation, by I can't seem to find a single actual command line call inside their many pages of how to write the comments section. I have this very simple file:
"""Main.py
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
"""
from docopt import docopt
if __name__ == '__main__':
arguments = docopt(__doc__, version='Main.py 1.0')
print(arguments)
I get the first part:
adams-mbp:Aut adam$ python main.py model
{'--help': 0,
'--outfile': None,
'--version': 0,
'Options:': False,
'Show': 0,
'controller': False,
'file.': False,
'form': False,
'model': True,
'screen.': False,
'this': False,
'version.': False}
But I can't seem to figure out how to pass an --outfile
parameter. Here's what I've tried:
adams-mbp:Aut adam$ python main.py main.py --outfile thing
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
adams-mbp:Aut adam$ python main.py main.py --outfile=thing
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
adams-mbp:Aut adam$ python --outfile thing main.py main.py
Unknown option: --
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
adams-mbp:Aut adam$ python --outfile=thing main.py main.py
Unknown option: --
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
adams-mbp:Aut adam$ python main.py main.py -outfile thing
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
adams-mbp:Aut adam$ python main.py main.py -outfile=thing
Naval Fate.
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
adams-mbp:Aut adam$ python main.py main.py outfile=thing
Usage:
main.py controller
main.py model
main.py form
main.py -h | --help
main.py --version
Options:
-h --help Show this screen.
--version Show version.
--outfile Output file.
Seriously?