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
[derive] Argument test
's selected action SetTrue contradicts takes_value
#5421
Comments
There are attributes that are implied by the data type, see https://docs.rs/clap/latest/clap/_derive/index.html#arg-types and if you aren't using the data type in the built-in way, then you have to override those. In this case, you need to set |
to my knowledge i am using data type
and
and also a example: fn cli() -> Command {
Command::new("prog")
.arg(Arg::new("create").long("create")
.value_name("BOOL")
.value_parser(value_parser!(bool))
.num_args(0..=1)
.require_equals(true)
.default_missing_value("true")
)
} Note: i just discovered I have now tested using |
The discrepancy is Builder vs Derive APIs. The Builder API defaults to I've tried to avoid as much talk about the Derive API in the Builder API. Part of this was from a negative experience as a user when clap had the Builder, YAML, and Usage APIs and each entry point was documented with the schema for them which made the docs more bloated and harder to follow. |
i can understand that, so maybe add it as a note when |
|
Please complete the following tasks
Rust Version
rustc 1.76.0 (07dca489a 2024-02-04)
Clap Version
4.5.3
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run -- --test=false
Actual Behaviour
Panic:
Expected Behaviour
No panic, as per documentation
default_missing_value
.Additional Context
i know that
default_missing_value
is currently not documented in derive attributes, but i thought it would work anyway.in case it is not clear, i am trying to do the following without problems:
Debug Output
The text was updated successfully, but these errors were encountered: