]> git.proxmox.com Git - rustc.git/blob - vendor/clap/examples/tutorial_builder/03_04_subcommands.md
New upstream version 1.65.0+dfsg1
[rustc.git] / vendor / clap / examples / tutorial_builder / 03_04_subcommands.md
1 ```console
2 $ 03_04_subcommands help
3 clap [..]
4 A simple to use, efficient, and full-featured Command Line Argument Parser
5
6 USAGE:
7 03_04_subcommands[EXE] <SUBCOMMAND>
8
9 OPTIONS:
10 -h, --help Print help information
11 -V, --version Print version information
12
13 SUBCOMMANDS:
14 add Adds files to myapp
15 help Print this message or the help of the given subcommand(s)
16
17 $ 03_04_subcommands help add
18 03_04_subcommands[EXE]-add [..]
19 Adds files to myapp
20
21 USAGE:
22 03_04_subcommands[EXE] add [NAME]
23
24 ARGS:
25 <NAME>
26
27 OPTIONS:
28 -h, --help Print help information
29 -V, --version Print version information
30
31 $ 03_04_subcommands add bob
32 'myapp add' was used, name is: Some("bob")
33
34 ```
35
36 Because we set [`Command::arg_required_else_help`][crate::Command::arg_required_else_help]:
37 ```console
38 $ 03_04_subcommands
39 ? failed
40 clap [..]
41 A simple to use, efficient, and full-featured Command Line Argument Parser
42
43 USAGE:
44 03_04_subcommands[EXE] <SUBCOMMAND>
45
46 OPTIONS:
47 -h, --help Print help information
48 -V, --version Print version information
49
50 SUBCOMMANDS:
51 add Adds files to myapp
52 help Print this message or the help of the given subcommand(s)
53
54 ```
55
56 Because we set [`Command::propagate_version`][crate::Command::propagate_version]:
57 ```console
58 $ 03_04_subcommands --version
59 clap [..]
60
61 $ 03_04_subcommands add --version
62 03_04_subcommands[EXE]-add [..]
63
64 ```