-
Is there a way to instruct #[derive(Parser, Debug)]
#[clap()]
struct MyArgs {
#[clap(short = 'I')]
important_arg: Vec<String>,
} the program will error out if I pass it e.g. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
For now we have https://docs.rs/clap/latest/clap/struct.App.html#method.ignore_errors Longer term we also want #1404 |
Beta Was this translation helpful? Give feedback.
-
My way: lazy_static! {
pub static ref ARGS: Args =
Args::from_arg_matches_mut(&mut Args::command().ignore_errors(true).get_matches(),)
.unwrap();
}
#[derive(Parser, Debug)]
pub struct Args {
#[command(subcommand)]
pub sub_command: Option<SubCommand>,
} Note: |
Beta Was this translation helpful? Give feedback.
-
If you want to ignore errors in derive API. #[derive(Parser, Debug)]
#[command(author, version, about, long_about = None, ignore_errors(true))]
struct Cli {
/// Include paths for proto files
#[arg(short, long, value_delimiter = ',')]
include_paths: Option<Vec<String>>,
} |
Beta Was this translation helpful? Give feedback.
For now we have https://docs.rs/clap/latest/clap/struct.App.html#method.ignore_errors
Longer term we also want #1404