]> git.proxmox.com Git - rustc.git/blame - vendor/clap-4.3.10/examples/tutorial_builder/04_02_parse.rs
New upstream version 1.73.0+dfsg1
[rustc.git] / vendor / clap-4.3.10 / examples / tutorial_builder / 04_02_parse.rs
CommitLineData
add651ee
FG
1use clap::{arg, command, value_parser};
2
3fn 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}