-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Get which arg of mutually exclusive ArgGroup was passed #2317
Comments
I think |
But that's not the thing he is asking for. |
she*, but I believe you're correct. |
Sorry for disturbing, haven't slept much yesterday and my mind isn't clear. So we need to design a new api specifically for fetching the triggered argument and also the value? @pksunkara . |
Yes, but this is not a priority for 3.0 |
Ideally, though I would also be fine with an API just for fetching the triggered argument — which would mean that getting the value of that argument would be a separate step. |
I'd like this as well but I'll be patient :) |
Currently, when we parse an argument and store its value in ArgMatches, we also store that value under the ArgGroup's name,, as was previously mentioned. With #3732, we've changed some things related to storing the value which is having me re-think it. In #3405, we are looking at defining actions to allow users to describe how a value should be written to the ArgMatches. #3748 is considering doing the same for arg groups which could include writing out which argument in an arg group was active. This doesn't let you access both the name and value but, as was mentioned, the user can look up the value. |
Now that `Id` is public, we can have `ArgMatches` report them. If we have to choose one behavior, this is more universal. The user can still look up the values, this works with groups whose args have different types, and this allows people to make decisions off of it when otherwise there isn't enogh information. Fixes clap-rs#2317 Fixes clap-rs#3748
Now that `Id` is public, we can have `ArgMatches` report them. If we have to choose one behavior, this is more universal. The user can still look up the values, this works with groups whose args have different types, and this allows people to make decisions off of it when otherwise there isn't enogh information. Fixes clap-rs#2317 Fixes clap-rs#3748
Make sure you completed the following tasks
Describe your use case
One of the use cases the documentation lists for
ArgGroup
is to have a set of mutually exclusive arguments (with.multiple(false)
), but the only way to get which of those arguments was passed is to callmatches.is_present(name)
for every argument in that group. It would be really nice if I could just get which argument of a mutually exclusive argument group was passed. Currently, to do this you have to check each argument individually, doing something like:Which is kind of tedious, and not very clean.
Describe the solution you'd like
Being able to write something like:
would be really nice.
value_of()
is just an example, there — I'm not particular about the exact API is to get this 🙂The text was updated successfully, but these errors were encountered: