with_additional_option/
main.rs1use {
2 clap::{CommandFactory, Parser},
3};
4
5
6#[derive(Parser, Debug)]
8#[command(name = "wao", author, version, about, disable_help_flag = true)]
9struct Args {
10 #[arg(long)]
12 help: bool,
13
14 #[arg(short, long, default_value = "9")]
16 height: u16,
17
18 #[arg(short, long, default_value = "3")]
20 width: u16,
21
22 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}