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
const VARIANTS: &'static [&'static str]
const VARIANTS: &'static [&'static str]
All possible argument choices, in display order.
Required methods
Parse an argument into Self
.