I would like to using docopt
for parsing a command line that can receive the same option multiple times. Could somebody explain me how to do it?
A test example:
#!/usr/bin/env python
"""
Test program.
Usage:
test.py -v
Options:
-v Flag that should be counted
"""
import docopt
print docopt.docopt(__doc__)
If I run this with test.py -v
, I get:
{'-v': True}
Where as if I run this with test.py -vv
, it displays the usage message (indicating the command line is not valid).
I'd like to tweak the option documentation so that docopt
returns me:
{'-v': 1}
When only 1 -v
was passed and:
{'-v': 3}
If, say, the user passed -vvv
. This is pretty much the same functionality the count
action in argparse.