aboutsummaryrefslogtreecommitdiff
path: root/structopt/examples/enum_in_args.rs
blob: 70347da77824efdb29b7a38b37114a938da5e9a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! How to use `arg_enum!` with `StructOpt`.

use clap::arg_enum;
use structopt::StructOpt;

arg_enum! {
    #[derive(Debug)]
    enum Baz {
        Foo,
        Bar,
        FooBar
    }
}

#[derive(StructOpt, Debug)]
struct Opt {
    /// Important argument.
    #[structopt(possible_values = &Baz::variants(), case_insensitive = true)]
    i: Baz,
}

fn main() {
    let opt = Opt::from_args();
    println!("{:?}", opt);
}