logo
pub trait ArgEnum: Sized {
    const VARIANTS: &'static [&'static str];

    fn from_str(input: &str, case_insensitive: bool) -> Result<Self, String>;
fn as_arg(&self) -> Option<&'static str>; }
Expand description

Parse arguments into enums.

When deriving Clap, a field whose type implements ArgEnum can have the attribute #[clap(arg_enum)]. In addition to parsing, help and error messages may report possible variants.

Example

#[derive(clap::Clap)]
struct Args {
    #[clap(arg_enum)]
    level: Level,
}

#[derive(clap::ArgEnum)]
enum Level {
    Debug,
    Info,
    Warning,
    Error,
}

Associated Constants

All possible argument choices, in display order.

Required methods

Parse an argument into Self.

The canonical argument value.

The value is None for skipped variants.

Implementors