Enum clap::ClapErrorType
[−]
[src]
pub enum ClapErrorType { InvalidValue, InvalidArgument, InvalidSubcommand, EmptyValue, ValueValidationError, ArgumentError, TooManyArgs, TooManyValues, TooFewValues, WrongNumValues, ArgumentConflict, MissingRequiredArgument, MissingSubcommand, MissingArgumentOrSubcommand, UnexpectedArgument, UnexpectedMultipleUsage, InvalidUnicode, HelpDisplayed, VersionDisplayed, InternalError, Io, Format, }
Command line argument parser error types
Variants
InvalidValue | Error occurs when some possible values were set, but clap found unexpected value Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug").index(1) .possible_value("fast") .possible_value("slow")) .get_matches_from_safe(vec!["", "other"]); |
InvalidArgument | Error occurs when clap found unexpected flag or option Exampleslet result = App::new("myprog") .arg(Arg::from_usage("-f, --flag 'some flag'")) .get_matches_from_safe(vec!["", "--other"]); |
InvalidSubcommand | Error occurs when clap found unexpected subcommand Exampleslet result = App::new("myprog") .subcommand(SubCommand::with_name("config") .about("Used for configuration") .arg(Arg::with_name("config_file") .help("The configuration file to use") .index(1))) .get_matches_from_safe(vec!["", "other"]); |
EmptyValue | Error occurs when option does not allow empty values but some was found Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug") .empty_values(false)) .arg(Arg::with_name("color")) .get_matches_from_safe(vec!["", "--debug", "--color"]); |
ValueValidationError | Option fails validation of a custom validator |
ArgumentError | Parser inner error |
TooManyArgs | Error occurs when an application got more arguments then were expected Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug").index(1) .max_values(2)) .get_matches_from_safe(vec!["", "too", "much", "values"]); |
TooManyValues | Error occurs when argument got more values then were expected Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug").index(1) .max_values(2)) .get_matches_from_safe(vec!["", "too", "much", "values"]); |
TooFewValues | Error occurs when argument got less values then were expected Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug").index(1) .min_values(3)) .get_matches_from_safe(vec!["", "too", "few"]); |
WrongNumValues | Error occurs when argument got a different number of values then were expected Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug").index(1) .max_values(2)) .get_matches_from_safe(vec!["", "too", "much", "values"]); |
ArgumentConflict | Error occurs when clap find two ore more conflicting arguments Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug") .conflicts_with("color")) .get_matches_from_safe(vec!["", "--debug", "--color"]); |
MissingRequiredArgument | Error occurs when one or more required arguments missing Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug") .required(true)) .get_matches_from_safe(vec![""]); |
MissingSubcommand | Error occurs when required subcommand missing Exampleslet result = App::new("myprog") .setting(AppSettings::SubcommandRequired) .subcommand(SubCommand::with_name("config") .about("Used for configuration") .arg(Arg::with_name("config_file") .help("The configuration file to use") .index(1))) .get_matches_from_safe(vec![""]); |
MissingArgumentOrSubcommand | Occurs when no argument or subcommand has been supplied and
Exampleslet result = App::new("myprog") .setting(AppSettings::ArgRequiredElseHelp) .subcommand(SubCommand::with_name("config") .about("Used for configuration") .arg(Arg::with_name("config_file") .help("The configuration file to use") .index(1))) .get_matches_from_safe(vec![""]); |
UnexpectedArgument | Error occurs when clap find argument while is was not expecting any Exampleslet result = App::new("myprog") .get_matches_from_safe(vec!["", "--arg"]); |
UnexpectedMultipleUsage | Error occurs when argument was used multiple times and was not set as multiple. Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug") .multiple(false)) .get_matches_from_safe(vec!["", "--debug", "--debug"]); |
InvalidUnicode | Error occurs when argument contains invalid unicode characters Exampleslet result = App::new("myprog") .arg(Arg::with_name("debug") .short("u") .takes_value(true)) .get_matches_from_safe(vec![OsString::from_vec(vec![0x20]), OsString::from_vec(vec![0xE9])]); assert!(result.is_err()); |
HelpDisplayed | Not a true 'error' as it means Exampleslet result = App::new("myprog") .get_matches_from_safe(vec!["", "--help"]); assert!(result.is_err()); assert_eq!(result.unwrap_err().error_type, ClapErrorType::HelpDisplayed); |
VersionDisplayed | Not a true 'error' as it means Exampleslet result = App::new("myprog") .get_matches_from_safe(vec!["", "--version"]); assert!(result.is_err()); assert_eq!(result.unwrap_err().error_type, ClapErrorType::VersionDisplayed); |
InternalError | Represents an internal error, please consider filing a bug report if this happens! |
Io | Represents an I/O error, typically white writing to stderr or stdout |
Format | Represents an Rust Display Format error, typically white writing to stderr or stdout |