1 //! How to use `arg_enum!` with `StructOpt`.
2 //!
3 //! Running this example with --help prints this message:
4 //! -----------------------------------------------------
5 //! structopt 0.3.25
6 //!
7 //! USAGE:
8 //! enum_in_args <i>
9 //!
10 //! FLAGS:
11 //! -h, --help Prints help information
12 //! -V, --version Prints version information
13 //!
14 //! ARGS:
15 //! <i> Important argument [possible values: Foo, Bar, FooBar]
16 //! -----------------------------------------------------
17
18 use clap::arg_enum;
19 use structopt::StructOpt;
20
21 arg_enum! {
22 #[derive(Debug)]
23 enum Baz {
24 Foo,
25 Bar,
26 FooBar
27 }
28 }
29
30 #[derive(StructOpt, Debug)]
31 struct Opt {
32 /// Important argument.
33 #[structopt(possible_values = &Baz::variants(), case_insensitive = true)]
34 i: Baz,
35 }
36
main()37 fn main() {
38 let opt = Opt::from_args();
39 println!("{:?}", opt);
40 }
41