2020-04-22 12:57:21 +02:00
|
|
|
//! Usage example of `arg_enum`
|
|
|
|
//!
|
|
|
|
//! All the variants of the enum and the enum itself support `rename_all`
|
|
|
|
|
2021-07-14 10:50:26 -05:00
|
|
|
use clap::{ArgEnum, Clap};
|
2020-04-22 09:25:41 +02:00
|
|
|
|
2021-07-14 10:50:26 -05:00
|
|
|
#[derive(ArgEnum, Debug, PartialEq)]
|
2020-04-22 09:25:41 +02:00
|
|
|
enum ArgChoice {
|
|
|
|
Foo,
|
|
|
|
Bar,
|
2020-04-22 12:57:21 +02:00
|
|
|
// Aliases are supported
|
|
|
|
#[clap(alias = "b", alias = "z")]
|
2020-04-22 09:25:41 +02:00
|
|
|
Baz,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clap, PartialEq, Debug)]
|
|
|
|
struct Opt {
|
|
|
|
#[clap(arg_enum)]
|
|
|
|
arg: ArgChoice,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let opt = Opt::parse();
|
|
|
|
println!("{:#?}", opt);
|
|
|
|
}
|