1 | use clap::{Parser, ValueEnum}; |
2 | |
3 | #[derive(Parser)] |
4 | #[command(author, version, about, long_about = None)] |
5 | struct Cli { |
6 | /// What mode to run the program in |
7 | #[arg(value_enum)] |
8 | mode: Mode, |
9 | } |
10 | |
11 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] |
12 | enum Mode { |
13 | /// Run swiftly |
14 | Fast, |
15 | /// Crawl slowly but steadily |
16 | /// |
17 | /// This paragraph is ignored because there is no long help text for possible values. |
18 | Slow, |
19 | } |
20 | |
21 | fn main() { |
22 | let cli = Cli::parse(); |
23 | |
24 | match cli.mode { |
25 | Mode::Fast => { |
26 | println!("Hare" ); |
27 | } |
28 | Mode::Slow => { |
29 | println!("Tortoise" ); |
30 | } |
31 | } |
32 | } |
33 | |