Suppose one has the following code:
#!/usr/bin/python
"""Does something.
Usage:
myprog.py --myopt=<myval>
Options:
--myopt=<myval> Some option [default: bla]
"""
arguments = docopt(__doc__)
print arguments
Is there a way to check whether the user gave a value for the option '--myopt', or left the default value unchanged?
I'd hate to repeat the default value in an if-statement like this:
if arguments['--myopt'] != 'bla':
or use a regex on __doc__
to extract the default value from the docstring. After all, docopt
already did parse the docstring.