-
Hi with clap v3.0 we have a lot of enum arguments that used
where the In clap v4 rc1-3
And while that builds, if one doesn't specify such an argument when parsing a command-line it panics on this instead of using the default type:
So must be something more missing in the translation of command definitions here from clap v3 to v4? We don't want to switch to On a related minor note, is there a way to enable case insensitive argument matching by default instead of specifying it on every argument? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
All the value parser knows is possible string values; you also need to set the appropriate type for it. #[arg(long, default_value_t, ignore_case = true, value_parser = clap::builder::PossibleValuesParser::new(OutputFormat::VARIANTS).map(|s| s.parse::<OutputFormat>().unwrap())]
pub output_format: OutputFormat, See also #3855
Not at the moment. That is an interesting thought though, if someone wants it on one arg, they probably want it on all args. I generally ignore that setting as I prefer to be case sensitive. |
Beta Was this translation helpful? Give feedback.
-
thanks that does work! should have searched better for previous threads, but thought this was something fully new in 4.0 rc. gets even more verbose, though I can probably do a utility function locally that is compatible with the |
Beta Was this translation helpful? Give feedback.
All the value parser knows is possible string values; you also need to set the appropriate type for it.
See also #3855
Not at the moment. That is an interesting thought though, if someone wants …