Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Clap Short arguments

  • short

  • We can allow to use -x short names (defaults to the first letter of the attribute)

  • We can set the letter ourselves.

use clap::Parser;

#[derive(Parser)]
struct Cli {
    #[arg(short)]
    debug: bool,

    #[arg(short = 'H')]
    host: String,
}

fn main() {
    let args = Cli::parse();
    println!("debug:   {}", args.debug);
    println!("host:    {}", args.host);
}