mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
25 lines
438 B
Rust
25 lines
438 B
Rust
//! Usage example of `arg_enum`
|
|
//!
|
|
//! All the variants of the enum and the enum itself support `rename_all`
|
|
|
|
use clap::Clap;
|
|
|
|
#[derive(Clap, Debug, PartialEq)]
|
|
enum ArgChoice {
|
|
Foo,
|
|
Bar,
|
|
// Aliases are supported
|
|
#[clap(alias = "b", alias = "z")]
|
|
Baz,
|
|
}
|
|
|
|
#[derive(Clap, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(arg_enum)]
|
|
arg: ArgChoice,
|
|
}
|
|
|
|
fn main() {
|
|
let opt = Opt::parse();
|
|
println!("{:#?}", opt);
|
|
}
|