2022-03-03 18:32:29 +00:00
|
|
|
// Note: this requires the `cargo` feature
|
|
|
|
|
2022-02-15 14:33:38 +00:00
|
|
|
use clap::{arg, command};
|
2022-02-08 04:50:39 +00:00
|
|
|
|
|
|
|
fn main() {
|
2022-02-15 14:33:38 +00:00
|
|
|
let matches = command!()
|
2022-02-08 04:50:39 +00:00
|
|
|
.arg(
|
|
|
|
arg!(<PORT>)
|
|
|
|
.help("Network port to use")
|
|
|
|
.validator(|s| s.parse::<usize>()),
|
|
|
|
)
|
|
|
|
.get_matches();
|
|
|
|
|
|
|
|
// Note, it's safe to call unwrap() because the arg is required
|
|
|
|
let port: usize = matches
|
|
|
|
.value_of_t("PORT")
|
|
|
|
.expect("'PORT' is required and parsing will fail if its missing");
|
|
|
|
println!("PORT = {}", port);
|
|
|
|
}
|