mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
ee3eab1614
Adds a more in depth validator to validate that the port is in range in the derive and builder tutorial (section 4.2). This supersedes #3416
15 lines
262 B
Rust
15 lines
262 B
Rust
use clap::Parser;
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author, version, about, long_about = None)]
|
|
struct Cli {
|
|
/// Network port to use
|
|
#[clap(parse(try_from_str))]
|
|
port: usize,
|
|
}
|
|
|
|
fn main() {
|
|
let cli = Cli::parse();
|
|
|
|
println!("PORT = {}", cli.port);
|
|
}
|