2021-12-15 17:12:16 +00:00
|
|
|
*Jump to [source](multicall-busybox.rs)*
|
2021-11-30 18:30:19 +00:00
|
|
|
|
2021-11-10 22:15:30 +00:00
|
|
|
Example of a busybox-style multicall program
|
|
|
|
|
2022-02-12 03:48:29 +00:00
|
|
|
See the documentation for `clap::Command::multicall` for rationale.
|
2021-11-10 22:15:30 +00:00
|
|
|
|
|
|
|
This example omits every command except true and false,
|
|
|
|
which are the most trivial to implement,
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-10 22:15:30 +00:00
|
|
|
$ busybox true
|
|
|
|
? 0
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-10 22:15:30 +00:00
|
|
|
$ busybox false
|
|
|
|
? 1
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-10 22:15:30 +00:00
|
|
|
```
|
2021-12-11 17:18:03 +00:00
|
|
|
*Note: without the links setup, we can't demonstrate the multicall behavior*
|
2021-11-10 22:15:30 +00:00
|
|
|
|
|
|
|
But includes the `--install` option as an example of why it can be useful
|
|
|
|
for the main program to take arguments that aren't applet subcommands.
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-10 22:15:30 +00:00
|
|
|
$ busybox --install
|
|
|
|
? failed
|
|
|
|
...
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-10 22:15:30 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Though users must pass something:
|
2022-01-05 16:54:33 +00:00
|
|
|
```console
|
2021-11-10 22:15:30 +00:00
|
|
|
$ busybox
|
|
|
|
? failed
|
|
|
|
busybox
|
|
|
|
|
|
|
|
USAGE:
|
2021-12-09 23:05:31 +00:00
|
|
|
busybox [OPTIONS] [APPLET]
|
2021-11-10 22:15:30 +00:00
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
-h, --help Print help information
|
|
|
|
--install <install> Install hardlinks for all subcommands in path
|
|
|
|
|
2021-11-17 20:20:52 +00:00
|
|
|
APPLETS:
|
2021-11-10 22:15:30 +00:00
|
|
|
false does nothing unsuccessfully
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
|
|
|
true does nothing successfully
|
2022-01-05 16:54:33 +00:00
|
|
|
|
2021-11-10 22:15:30 +00:00
|
|
|
```
|