summaryrefslogtreecommitdiffstats
path: root/third_party/rust/clap/examples/derive_ref/custom-bool.md
blob: 2769f20e8f9a24c5e197629b8ff1a9a8a0860ad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
*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>

ARGS:
    <BOOM>    

OPTIONS:
        --bar <BAR>    [default: false]
        --foo <FOO>    
    -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] [OPTIONS] --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,
}

```