• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use clap::{arg, command, value_parser};
2 
main()3 fn main() {
4     let matches = command!() // requires `cargo` feature
5         .arg(
6             arg!(<PORT>)
7                 .help("Network port to use")
8                 .value_parser(value_parser!(u16).range(1..)),
9         )
10         .get_matches();
11 
12     // Note, it's safe to call unwrap() because the arg is required
13     let port: u16 = *matches
14         .get_one::<u16>("PORT")
15         .expect("'PORT' is required and parsing will fail if its missing");
16     println!("PORT = {}", port);
17 }
18