docopt.go
docopt.go copied to clipboard
List flags
I was recently surprised to discover that while arguments can be repeated, flags cannot. e.g. these are acceptable docstrings, but they don't behave as expected:
-v verbose (specify multiple times for more verbose)
-x=<pattern>... exclude files that match <pattern>
Neither of these cases seem to be addressed, although they're pretty common. The "verbose" case I kind of understand, since it'd take some kind of docstring magic to indicate to the parse what's meant. But the "exclude" seems to fall within the documentation as written for docopt, and instead returns a parsing error.
This is effectively "can we have https://github.com/docopt/docopt/issues/275 ?"
This duplicates issue #29
@gdey I don't agree. #29 is about having the same flag documented twice to mean different things in different contexts. I think that's maybe reasonable and not too difficult if the flag always is the same kind.
This is about accepting -vvvv => map[string]interface{}{"v": 4} or -x=bad -x=worse => {"x": []string{"bad","worse"}
Note @nyarly : -vvvv returns "-v": 4 or 3 or2 or 1 or 0 if omitted. This works; haven't tried the other one.