Docopt: Is it possible to specify repeating positional argument followed by a single positional argument?

188 Views Asked by At

I have a simple python script that uses docopt to parse command line arguments. It looks like this:

#!/usr/bin/env python

__doc__ = """
Usage: mycopy <src>... <dest>
"""
from docopt import docopt

options = docopt(__doc__)

When I run it:

./mycopy source1/ source2/ destination/

it just prints the usage info, meaning that the command line arguments I passed it were wrong. Is something wrong with the usage spec? Is it even possible to do something like this using docopt?

1

There are 1 best solutions below

1
On

If you put <dest> before <src>..., it works. Accordingly, run it with ./mycopy destination/ source1/ source2/.

I think the docopt hasn't implemented the support for: ARGS... ARG. This case adds some complexity to the implementation. But I agree 'copy src1 src2 ... dest' is more straightforward usage. So maybe you could raise a request to this project: https://github.com/docopt/docopt