-
-
Notifications
You must be signed in to change notification settings - Fork 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
Combining ArgAction::Count
and TypedValueParser::map
doesn't seem to work.
#5804
Comments
When you pass For this to work, we'd need to do one of the following
As for workarounds... We take the "intermediate" struct approach in https://docs.rs/clap-verbosity-flag/latest/clap_verbosity_flag/ The conversion can also be a helper method on |
This seems solvable by introducing a trait called something like
Could you elaborate on this point? Yes, likely this new trait would be closely coupled to |
We are effectively operating on a
I was specifically referring to baking in the information for this behavior in |
Please complete the following tasks
Rust Version
rustc 1.82.0 (f6e511eec 2024-10-15)
Clap Version
4.5.19
Minimal reproducible code
playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=ba6ae5eae9e9514d276dc40d5479cf5e
Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
At runtime, clap panics with the following message:
Expected Behaviour
I would expect that the value parser is called to produce a
u8
and thenCleanLevel::from_val
is called on the parsed value to map to anOption<CleanLevel>
. It seems the sequence of events in parsing is somehow wrong, or maybe I'm misunderstanding howMapValueParser
works.Additional Context
The alternative solution is to make use of an intermediate struct and a method on that struct, like so:
However, this introduces extra clutter and indirection. It would be great to avoid using an intermediate representation.
Debug Output
No response
The text was updated successfully, but these errors were encountered: