python's docopt treats command like a parameter with itself as a value

261 Views Asked by At

My code is this:

#!/usr/bin/python3
"""
Usage:
  mymodule foobar   [options]
  mymodule WOS      [options]

Options:
  -h --help     Show this screen
  -f --force-update        Re-scan downloaded issues in plot mode

"""
import docopt

if __name__=='__main__':

    # Parse arguments, use file docstring as a parameter definition
    arguments = docopt.docopt(__doc__)
    print(arguments)

and I save the above as mymodule.py and then run mymodule.py WOS. The output is

{'--force-update': False,
 '--help': False,
 'WOS': 'WOS',
 'foobar': False}

That's not right! The value of WOS should be True, not "WOS" ! I use docopt heavily and have for years. Am I too tired, or is this a new bug?

0

There are 0 best solutions below