Skip to content
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

Push indices for arguments taking optional values #4909

Closed
wants to merge 1 commit into from

Conversation

fabianfreyer
Copy link

When an argument takes an optional value (e.g. .num_args(0..=1)), make sure an index is pushed:

  • when a value is specified, for each value
  • when no value is specified, for the option, similar to a flag.

Note: this means that a MatchedArg's num_vals no longer necessarily matches the number of indices.

Fixes #2419

When an argument takes an optional value (e.g. `.num_args(0..=1)`), make
sure an index is pushed:
* when a value is specified, for each value
* when no value is specified, for the option, similar to a flag.

Note: this means that a MatchedArg's `num_vals` no longer necessarily
matches the number of indices.

Fixes clap-rs#2419
@epage
Copy link
Member

epage commented May 15, 2023

Let's agree on requirements and solution before moving to a PR

@fabianfreyer
Copy link
Author

fabianfreyer commented May 15, 2023

Sure! This was really just meant to be a prototype / basis for discussion in #2419, since that seemed to have ground to a halt -- happy to continue the discussion over there.
Sorry if I jumped the gun by opening a PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using index_of()/indices_of() with optional arguments that take optional values
2 participants