docopt/docopt — pull request #46 by shabbyrobe (2012-08-11 12:03:11+00:00)
Title: Allows one or more fixed arguments after a repeating argument

I was having trouble with a script that uses the "multiple sources followed by a target" scheme you see in `cp` and `mv`:

```python
import docopt

if __name__ == "__main__":
args = docopt.docopt("Usage: cp [-hv] ... ")
print args
```

docopt currently just eats all arguments into ``, so the script borks on usage.

This pull request implements support for looking ahead and seeing if the next object in the parent of a OneOrMany is an Argument, and tries to avoid swallowing more than necessary. The patch itself is rather hacky and not really up to snuff, particularly the bit where the parent gets assigned. I'm also not 100% sure how fix_list_arguments impacts on the ability to treat the result of parse_pattern as a full tree.

I've submitted it anyway as more of a demonstration for how I "solved" the problem in the hope that we can use it as a stepping-off point for doing it right (assuming, of course, it's agreed that docopt should support this!)