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