Enum clap::ClapErrorType [] [src]

pub enum ClapErrorType {
    InvalidValue,
    InvalidArgument,
    InvalidSubcommand,
    EmptyValue,
    OptionError,
    ArgumentError,
    ValueError,
    TooMuchValues,
    TooFewValues,
    ArgumentConflict,
    MissingRequiredArgument,
    MissingSubcommand,
    UnexpectedArgument,
    UnexpectedMultipleUsage,
}

Command line argument parser error types

Variants

InvalidValue

Error occurs when some possible values were set, but clap found unexpected value

Example

let 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

Example

let 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

Example

let result = App::new("myprog")
    .subcommand(SubCommand::with_name("conifg")
        .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

Example

let result = App::new("myprog")
    .arg(Arg::with_name("debug")
         .empty_values(false))
    .arg(Arg::with_name("color"))
    .get_matches_from_safe(vec!["", "--debug", "--color"]);
OptionError

Parser inner error

ArgumentError

Parser inner error

ValueError

Parser inner error

TooMuchValues

Error occurs when argument got more values then were expected

Example

let 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

Example

let result = App::new("myprog")
    .arg(Arg::with_name("debug").index(1)
        .min_values(3))
    .get_matches_from_safe(vec!["", "too", "few"]);
ArgumentConflict

Error occurs when clap find two ore more conflicting arguments

Example

let 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

Example

let result = App::new("myprog")
    .arg(Arg::with_name("debug")
        .required(true))
    .get_matches_from_safe(vec![""]);
MissingSubcommand

Error occurs when required subcommand missing

Example

let result = App::new("myprog")
    .setting(AppSettings::SubcommandRequired)
    .subcommand(SubCommand::with_name("conifg")
        .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

Example

let 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.

Example

let result = App::new("myprog")
    .arg(Arg::with_name("debug")
        .multiple(false))
    .get_matches_from_safe(vec!["", "--debug", "--debug"]);

Trait Implementations

impl Debug for ClapErrorType
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl PartialEq for ClapErrorType
[src]

fn eq(&self, __arg_0: &ClapErrorType) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.