Debian Codegraph @

debian/missing-sources/clap/examples/tutorial_builder/03_04_subcommands.md

raw symbols SCIP
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 We set
33 [`Command::arg_required_else_help`][crate::Command::arg_required_else_help] to
34 show the help, rather than an error, when the
35 [required subcommand][crate::Command::subcommand_required] is missing:
36 ```console
37 $ 03_04_subcommands
38 ? failed
39 A simple to use, efficient, and full-featured Command Line Argument Parser
40
41 Usage: 03_04_subcommands[EXE] <COMMAND>
42
43 Commands:
44 add Adds files to myapp
45 help Print this message or the help of the given subcommand(s)
46
47 Options:
48 -h, --help Print help
49 -V, --version Print version
50
51 ```
52
53 Since we specified [`Command::propagate_version`][crate::Command::propagate_version], the `--version` flag
54 is available in all subcommands:
55 ```console
56 $ 03_04_subcommands --version
57 clap [..]
58
59 $ 03_04_subcommands add --version
60 clap-add [..]
61
62 ```