1 | use clap::{arg, command, value_parser}; |
---|---|
2 | |
3 | fn main() { |
4 | let matches = command!() // requires `cargo` feature |
5 | .arg( |
6 | arg!([PORT]) |
7 | .value_parser(value_parser!(u16)) |
8 | .default_value("2020"), |
9 | ) |
10 | .get_matches(); |
11 | |
12 | println!( |
13 | "port: {:?}", |
14 | matches |
15 | .get_one::<u16>("PORT") |
16 | .expect("default ensures there is always a value") |
17 | ); |
18 | } |
19 |