2
"""
Usage:
program (--opt=OPT...) (--ano=ANO...)

Options:
  --opt=OPT    An option that can be specified multiple times to form a list
  --ano=ANO    An option that can be specified multiple times to form a list
"""

import docopt
print docopt.docopt(__doc__)

With the code above the following works:

python program.py --opt 1.txt --opt 4.txt --ano 2.txt --ano 3.txt
{'--ano': ['2.txt', '3.txt'],
 '--opt': ['1.txt', '4.txt']}

However, I'd like the following to work too (so that globbing is supported):

python program.py --opt 1.txt 4.txt --ano 2.txt 3.txt
Usage:
program (--opt=OPT...) (--ano=ANO...)

Like this:

python program --opt *.txt --ano *.csv

Can I achieve this with docopt?

The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
  • One bad way to do this would be to accept a glob, like this: '*.csv' and get the files myself. Then I cannot use the fish shell's awesome globbing though... – The Unfun Cat Sep 16 '15 at 12:08

0 Answers0