Ability to set min_values per occurance when multiple_occurances is used #3542
Labels
A-parsing
Area: Parser's logic and needs it changed somehow.
C-enhancement
Category: Raise on the bar on expectations
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
M-breaking-change
Meta: Implementing or merging this will introduce a breaking change.
Milestone
Please complete the following tasks
Clap Version
3.1.5
Describe your use case
I have an option that supports multiple occurrences, but each occurrence is independent, and needs a minimum of 1 value passed to it. I'm using
grouped_values_of
to get the groups of values. If I use.min_values(1)
, then it requires that there is at least one value in total, not that there is one value per occurance.Here's some example code:
This produces a successful match, but I want it to fail, because no argument is given to the second occurance of
-x
.Describe the solution you'd like
Ideally,
.min_values
would behave as I've described. And if the current behavior is unintentional , then this is probably a bug, and it might be worth changing. However, changingmin_values
's behavior would technically be backwards incompatible, so it may be necessary to introduce a new api likemin_values_per_occurance
(and probably a similarmax_values_per_occurance
).Alternatives, if applicable
The only alternative I know of is to have the application check that enough arguments are provided to each group returned by
grouped_values_of
rather than letting clap do the validation for me.Additional Context
See sharkdp/fd#960 (comment).
The text was updated successfully, but these errors were encountered: