]> git.proxmox.com Git - rustc.git/blob - vendor/clap/examples/tutorial_builder/03_04_subcommands.md
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / clap / examples / tutorial_builder / 03_04_subcommands.md
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 Because we set [`Command::propagate_version`][crate::Command::propagate_version]:
51 ```console
52 $ 03_04_subcommands --version
53 clap [..]
54
55 $ 03_04_subcommands add --version
56 clap-add [..]
57
58 ```