Replies: 2 comments 8 replies
-
When implementing a Take Alternatively, you could reuse one of the existing |
Beta Was this translation helpful? Give feedback.
-
Hi @epage, may I ask on the flip side, is there an easy way to prevent the printing of "For more information ..." when I used the value_parser ? In my below code, although I have overridden the error message, the "For more information..." is still printed at the end of the message #[derive(clap::Parser, Default, Debug)]
#[command()]
struct Args {
#[arg(value_parser = parse_version)]
version: Version,
}
fn parse_version(s: &str) -> Result<Version, String> {
Version::from_str(s).map_err(|_| {
format!(
"Failed to parse VERSION: '{}'!",
s
)
})
} |
Beta Was this translation helpful? Give feedback.
-
I was trying to print an error message from my custom
TypedValueParser
and noticed that it prints the error message, but the line "For more information, try '--help'" is not printed at the end of output.If I use
Fn(&str) -> Result<T, E>
instead ofTypedValueParser
, the "For more info" line is printed at the end as I wanted.I want to print the line "For more information, try '--help'" from
TypedValueParser
. How can I do this?Steps to reproduce
To reproduce, please copy the following main.rs and dependencies into your new testing project, and follow these steps:
cargo run
and check its output.test_typed_value_parser();
.test_function();
.cargo run
and check its output.main.rs
[dependencies] in Cargo.toml
The output from
TypedValueParser
error: Error from ColorParser
The output from
Fn(&str) -> Result<T, E>
Beta Was this translation helpful? Give feedback.
All reactions