-
Notifications
You must be signed in to change notification settings - Fork 87
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
Feature Request: choices #138
Comments
Yeah this would be interesting. We don’t have a built in way to do this at the moment, but you could use a helper function to do it. See this test for an example: https://github.com/google/argh/blob/master/argh/tests/lib.rs#L67. You’d just have to manually parse the argument into your enum. |
My preference for this would be another proc macro to annotate enums with, similar to how sub-commands are defined, except that these enums would not be allowed to have any data associated. Clap has this feature and calls it |
@bbstilson this is definitely possible with current Good Luck! |
This would be very nice for ergonomics. It would also mean that |
Yeah. Currently, setting up an enum with
...where the help menu then fails to actually provide any more information, so the message is just leading the users on a wild goose chase. Thus, for now, I'm taking in string input and running parsing-into-enum on it later, within the function-that-uses-that-arg, with a manually-specified helpful error message. But, if more properly supported enum-choices-input were enabled, that'd be very nice as an upgrade over that sort of manual handling. |
Similar to the click arg parse library from Python, it would be nice if
argh
had a similar feature. I am new to rust, so I can't suggest a good interface, but perhaps something like:but an enum might be a better option:
Perhaps this is possible already, but I couldn't figure out how to do so given the example and readme. Happy to close this if it is already possible.
Thanks!
The text was updated successfully, but these errors were encountered: