mirror of
https://github.com/clap-rs/clap
synced 2025-01-07 10:18:48 +00:00
0c9b9d7ec8
This also has the side effect of always using the "smart usage" which is why the tests changed.
47 lines
990 B
Markdown
47 lines
990 B
Markdown
*Jump to [source](custom-bool.rs)*
|
|
|
|
Example of overriding the magic `bool` behavior
|
|
|
|
```console
|
|
$ custom-bool --help
|
|
clap [..]
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
Usage:
|
|
custom-bool[EXE] [OPTIONS] --foo <FOO> <BOOM>
|
|
|
|
Arguments:
|
|
<BOOM> [possible values: true, false]
|
|
|
|
Options:
|
|
--foo <FOO> [possible values: true, false]
|
|
--bar <BAR> [default: false]
|
|
-h, --help Print help information
|
|
-V, --version Print version information
|
|
|
|
$ custom-bool
|
|
? failed
|
|
error: The following required arguments were not provided:
|
|
--foo <FOO>
|
|
<BOOM>
|
|
|
|
Usage:
|
|
custom-bool[EXE] --foo <FOO> <BOOM>
|
|
|
|
For more information try --help
|
|
|
|
$ custom-bool --foo true false
|
|
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
|
|
foo: true,
|
|
bar: false,
|
|
boom: false,
|
|
}
|
|
|
|
$ custom-bool --foo true --bar true false
|
|
[examples/derive_ref/custom-bool.rs:31] opt = Opt {
|
|
foo: true,
|
|
bar: true,
|
|
boom: false,
|
|
}
|
|
|
|
```
|