I'd like to design my command line application in a way that one option, let's call it comment, can be specified several times, e.g.,
$ ./my_app.py --comment="Comment 1" --comment="Comment 2"
Can this be done with docopt? I checked the docopt homepage but couldn't find any reference to multiple occurences of the same optional argument.
For reference, the official docs can be found here at github.
To answer your specific question, you can use an ellipse
...
with your optional option[--my-option]
and specify that your option takes an argument.I.e.
[--my-option=ARG]...
or[--my-option=<arg>]...
Example:
By specifying it as
[--comment=<arg>]...
you ensure that opt['--comment'] is a list of all the specified comments.Executing:
my_program --comment=ASDF --comment=QWERTY my_file
Leads to: