Skip to main content

#
04_02_parse_derive/
04_02_parse.rs

    1use clap::Parser;
    2
    3#[derive(Parser)]
    4#[command(version, about, long_about = None)]
    5struct Cli {
    6    /// Network port to use
    7    #[arg(value_parser = clap::value_parser!(u16).range(1..))]
    8    port: u16,
    9}
    10
    11fn main() {
    12    let cli = Cli::parse();
    13
    14    println!("PORT = {}", cli.port);
    15}