with_additional_option/
main.rs

1use {
2    clap::{CommandFactory, Parser},
3};
4
5
6/// Application launch arguments
7#[derive(Parser, Debug)]
8#[command(name = "wao", author, version, about, disable_help_flag = true)]
9struct Args {
10    /// Print help
11    #[arg(long)]
12    help: bool,
13
14    /// Height, that is the distance between bottom and top
15    #[arg(short, long, default_value = "9")]
16    height: u16,
17
18    /// Width, from there, to there, eg `4` or `5`
19    #[arg(short, long, default_value = "3")]
20    width: u16,
21
22    /// Root Directory
23    pub root: Option<std::path::PathBuf>,
24}
25
26pub fn print_help() {
27    let mut printer = clap_help::Printer::new(Args::command())
28        .without("author");
29    printer
30        .expander_mut()
31        .sub("option-lines")
32        .set("short", "-z")
33        .set("long", "--zeta")
34        .set("value", "ZETA")
35        .set("help", "Set the index of the last letter of the greek alphabet");
36    printer.print_help();
37}
38
39fn main() {
40    let args = Args::parse();
41
42    if args.help {
43        print_help();
44        return;
45    }
46
47    let (w, h) = (args.width, args.height);
48    println!("{w} x {h} = {}", w * h);
49}