docopt.go icon indicating copy to clipboard operation
docopt.go copied to clipboard

List flags

Open nyarly opened this issue 9 years ago • 4 comments

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.

nyarly avatar Aug 04 '16 17:08 nyarly

This is effectively "can we have https://github.com/docopt/docopt/issues/275 ?"

nyarly avatar Aug 04 '16 17:08 nyarly

This duplicates issue #29

gdey avatar Aug 17 '16 18:08 gdey

@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"}

nyarly avatar Aug 17 '16 18:08 nyarly

Note @nyarly : -vvvv returns "-v": 4 or 3 or2 or 1 or 0 if omitted. This works; haven't tried the other one.

fenollp avatar Jan 23 '18 11:01 fenollp