1use {
2 clap::{CommandFactory, Parser, ValueEnum},
3 clap_help::Printer,
4};
5
6static INTRO: &str = "
7Compute `height x width`
8*You can do it either precisely (enough) or fast (I mean not too slow)*.
9";
10
11#[derive(Parser, Debug)]
13#[command(name = "area", author, version, about, disable_help_flag = true)]
14struct Args {
15 #[arg(long)]
17 help: bool,
18
19 #[arg(short, long, default_value = "9")]
21 height: u16,
22
23 #[arg(short, long, default_value = "3")]
25 width: u16,
26
27 #[arg(short, long)]
29 kill_birds: bool,
30
31 #[arg(long, default_value = "fast")]
33 strategy: Strategy,
34
35 #[arg(short, long, value_name = "SEP")]
37 separator: Option<String>,
38
39 pub root: Option<std::path::PathBuf>,
41}
42
43#[derive(ValueEnum, Clone, Copy, Debug)]
44enum Strategy {
45 Fast,
46 Precise,
47}
48
49fn main() {
50 let args = Args::parse();
51
52 if args.help {
53 Printer::new(Args::command())
54 .with("introduction", INTRO)
55 .without("author")
56 .print_help();
57 return;
58 }
59
60 let (w, h) = (args.width, args.height);
61 println!("Computation strategy: {:?}", args.strategy);
62 println!("{w} x {h} = {}", w * h);
63}