1 | use clap::Parser; |
---|---|
2 | |
3 | /// Simple program to greet a person |
4 | #[derive(Parser, Debug)] |
5 | #[command(author, version, about, long_about = None)] |
6 | struct Args { |
7 | /// Name of the person to greet |
8 | #[arg(short, long)] |
9 | name: String, |
10 | |
11 | /// Number of times to greet |
12 | #[arg(short, long, default_value_t = 1)] |
13 | count: u8, |
14 | } |
15 | |
16 | fn main() { |
17 | let args = Args::parse(); |
18 | |
19 | for _ in 0..args.count { |
20 | println!("Hello {}!", args.name) |
21 | } |
22 | } |
23 |