1 // Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8
9 use structopt::StructOpt;
10
11 #[derive(StructOpt, Debug)]
12 #[structopt(name = "make-cookie")]
13 struct MakeCookie {
14 #[structopt(short)]
15 s: String,
16
17 #[structopt(subcommand, flatten)]
18 cmd: Command,
19 }
20
21 #[derive(StructOpt, Debug)]
22 enum Command {
23 #[structopt(name = "pound")]
24 /// Pound acorns into flour for cookie dough.
25 Pound { acorns: u32 },
26
27 Sparkle {
28 #[structopt(short)]
29 color: String,
30 },
31 }
32
main()33 fn main() {
34 let opt = MakeCookie::from_args();
35 println!("{:?}", opt);
36 }
37