2021-12-15 11:12:16 -06:00
|
|
|
*Jump to [source](custom-bool.rs)*
|
2021-12-09 09:32:33 -06:00
|
|
|
|
|
|
|
Example of overriding the magic `bool` behavior
|
|
|
|
|
2022-01-05 17:54:33 +01:00
|
|
|
```console
|
2021-12-15 11:12:16 -06:00
|
|
|
$ custom-bool --help
|
2021-12-09 09:32:33 -06:00
|
|
|
clap [..]
|
|
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Usage:
|
2021-12-15 11:12:16 -06:00
|
|
|
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
|
2021-12-09 09:32:33 -06:00
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Arguments:
|
2022-06-01 10:31:23 -05:00
|
|
|
<BOOM> [possible values: true, false]
|
2021-12-09 09:32:33 -06:00
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Options:
|
2022-06-01 10:31:23 -05:00
|
|
|
--foo <FOO> [possible values: true, false]
|
2022-07-22 15:43:49 -05:00
|
|
|
--bar <BAR> [default: false]
|
2021-12-09 09:32:33 -06:00
|
|
|
-h, --help Print help information
|
|
|
|
-V, --version Print version information
|
2022-01-05 17:54:33 +01:00
|
|
|
|
2021-12-15 11:12:16 -06:00
|
|
|
$ custom-bool
|
2021-12-09 09:32:33 -06:00
|
|
|
? failed
|
|
|
|
error: The following required arguments were not provided:
|
|
|
|
--foo <FOO>
|
|
|
|
<BOOM>
|
|
|
|
|
2022-08-26 09:40:23 -05:00
|
|
|
Usage:
|
2021-12-15 11:12:16 -06:00
|
|
|
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
|
2021-12-09 09:32:33 -06:00
|
|
|
|
|
|
|
For more information try --help
|
2022-01-05 17:54:33 +01:00
|
|
|
|
2021-12-15 11:12:16 -06:00
|
|
|
$ custom-bool --foo true false
|
2022-06-01 10:31:23 -05:00
|
|
|
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
|
2021-12-09 09:32:33 -06:00
|
|
|
foo: true,
|
|
|
|
bar: false,
|
|
|
|
boom: false,
|
|
|
|
}
|
2022-01-05 17:54:33 +01:00
|
|
|
|
2021-12-15 11:12:16 -06:00
|
|
|
$ custom-bool --foo true --bar true false
|
2022-06-01 10:31:23 -05:00
|
|
|
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
|
2021-12-09 09:32:33 -06:00
|
|
|
foo: true,
|
|
|
|
bar: true,
|
|
|
|
boom: false,
|
|
|
|
}
|
2022-01-05 17:54:33 +01:00
|
|
|
|
2021-12-09 09:32:33 -06:00
|
|
|
```
|