docopt / docopt.go

A command-line arguments parser that will make you smile.
http://docopt.org/
MIT License
1.43k stars 108 forks source link

List flags #36

Open nyarly opened 8 years ago

nyarly commented 8 years ago

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 commented 8 years ago

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

gdey commented 8 years ago

This duplicates issue #29

nyarly commented 8 years ago

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

fenollp commented 6 years ago

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