Replies: 1 comment 4 replies
-
Great idea! We can do this after 3.0 since it's not a breaking change.
How would that work for positional args?
I don't know why they are being discussed here, because if you use delimiter, I don't think you can use multiple values. It's just 1 value during parsing which uses delimiter to get more values in the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, we have
takes_value
multiple_values
min_values
max_values
We then have to clarify how these are related to each other, for example:
(taken from docs.rs, since updated to say
multiple_occurrences
).I had already been brainstorming on this idea when kbknapp mentioned
I think we can simplify this problem down to
takes_values(num: impl clap::IntoRange)
withimpl IntoRange for usize
impl IntoRange for
...each range typeSo you can do
take_values(0)
,take_values(2)
,take_values(1..)
,take_values(0..=1)
bool
, but I think that is making it too magical and isn't as needed.takes_values(1)
being the default.While I was already talking with kbknapp, I brought this up and is thoughts were:
Notes
For the question from kbknapp
I would say occurrences, actually. This would leave room for the two features to compose, like
multiple_occurrences(true).takes_values(2)
. Not a common pattern but I think it speaks to an API when the features compose together in a natural way which this allows.RE Delimiters
I would posit that common cases for multiple values are
0..=1
2
0..
or1..
with a delimiterWe should raise awareness of
require_delimiter
in the docs fortake_values
.Benefits
Beta Was this translation helpful? Give feedback.
All reactions