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