Debian Codegraph @

third_party/rust/clap/examples/tutorial_builder/03_04_subcommands.md

raw
1 ```console
2 $ 03_04_subcommands help
3 A simple to use, efficient, and full-featured Command Line Argument Parser
4
5 Usage: 03_04_subcommands[EXE] <COMMAND>
6
7 Commands:
8 add Adds files to myapp
9 help Print this message or the help of the given subcommand(s)
10
11 Options:
12 -h, --help Print help
13 -V, --version Print version
14
15 $ 03_04_subcommands help add
16 Adds files to myapp
17
18 Usage: 03_04_subcommands[EXE] add [NAME]
19
20 Arguments:
21 [NAME]
22
23 Options:
24 -h, --help Print help
25 -V, --version Print version
26
27 $ 03_04_subcommands add bob
28 'myapp add' was used, name is: Some("bob")
29
30 ```
31
32 Because we set [`Command::arg_required_else_help`][crate::Command::arg_required_else_help]:
33 ```console
34 $ 03_04_subcommands
35 ? failed
36 A simple to use, efficient, and full-featured Command Line Argument Parser
37
38 Usage: 03_04_subcommands[EXE] <COMMAND>
39
40 Commands:
41 add Adds files to myapp
42 help Print this message or the help of the given subcommand(s)
43
44 Options:
45 -h, --help Print help
46 -V, --version Print version
47
48 ```
49
50 Since we specified [`Command::propagate_version`][crate::Command::propagate_version], the `--version` flag
51 is available in all subcommands:
52 ```console
53 $ 03_04_subcommands --version
54 clap [..]
55
56 $ 03_04_subcommands add --version
57 clap-add [..]
58
59 ```