2022-07-19 13:29:31 -05:00
|
|
|
```console
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive help
|
2022-07-19 13:29:31 -05:00
|
|
|
clap [..]
|
|
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Usage:
|
2022-08-08 14:05:08 -05:00
|
|
|
03_04_subcommands_derive[EXE] <SUBCOMMAND>
|
2022-07-19 13:29:31 -05:00
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Options:
|
2022-07-19 13:29:31 -05:00
|
|
|
-h, --help Print help information
|
|
|
|
-V, --version Print version information
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Subcommands:
|
2022-07-19 13:29:31 -05:00
|
|
|
add Adds files to myapp
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
|
|
|
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive help add
|
2022-07-23 21:55:30 -05:00
|
|
|
clap-add [..]
|
2022-07-19 13:29:31 -05:00
|
|
|
Adds files to myapp
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Usage:
|
2022-08-08 14:05:08 -05:00
|
|
|
03_04_subcommands_derive[EXE] add [NAME]
|
2022-07-19 13:29:31 -05:00
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Arguments:
|
2022-07-19 13:29:31 -05:00
|
|
|
<NAME>
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Options:
|
2022-07-19 13:29:31 -05:00
|
|
|
-h, --help Print help information
|
|
|
|
-V, --version Print version information
|
|
|
|
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive add bob
|
2022-07-19 13:29:31 -05:00
|
|
|
'myapp add' was used, name is: Some("bob")
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Because we used `command: Commands` instead of `command: Option<Commands>`:
|
|
|
|
```console
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive
|
2022-07-19 13:29:31 -05:00
|
|
|
? failed
|
|
|
|
clap [..]
|
|
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Usage:
|
2022-08-08 14:05:08 -05:00
|
|
|
03_04_subcommands_derive[EXE] <SUBCOMMAND>
|
2022-07-19 13:29:31 -05:00
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Options:
|
2022-07-19 13:29:31 -05:00
|
|
|
-h, --help Print help information
|
|
|
|
-V, --version Print version information
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Subcommands:
|
2022-07-19 13:29:31 -05:00
|
|
|
add Adds files to myapp
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Because we added `#[clap(propagate_version = true)]`:
|
|
|
|
```console
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive --version
|
2022-07-19 13:29:31 -05:00
|
|
|
clap [..]
|
|
|
|
|
2022-08-08 14:05:08 -05:00
|
|
|
$ 03_04_subcommands_derive add --version
|
2022-07-22 11:40:30 -05:00
|
|
|
clap-add [..]
|
2022-07-19 13:29:31 -05:00
|
|
|
|
|
|
|
```
|