-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for enumerations #45
Comments
There is support for this in the form of args = docopt(...)
if args['<direction>'] not in ['north', 'west', 'east', 'south']:
raise SomeException |
This could be done for options with arguments:
but dunno how to do it nicely for positional arguments... |
We've already got syntax for default values, which seems to me to be a intuitive basis for this (and other argument value metadata stuff, like in #8.) If/when #37 gets implemented, it would naturally also apply to positional arguments. Something like this:
Vis-a-vis prior art, the only programs I could think of that have arguments like this were xrandr and xsetwacom, who communicate the idea with
But I don't really like any of them. |
Maybe this should be dropped (similar to #8) in favor of using schema-validation tools instead, like in this example: https://github.com/docopt/docopt/blob/master/examples/validation_example.py |
This issue is a special case of #52, further discussion is directed there. |
We can already do this:
But this uses subcommands, which have an awkward access syntax, and issues #42 and #4 suggest to me they're meant for something rather more heavy-duty. Moreover, the set of legal values might be too verbose or too large to enumerate in an usage pattern. In such cases, something like this would be more useful:
The text was updated successfully, but these errors were encountered: