mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
docs(tutorial): Link derive to builder API
This commit is contained in:
parent
253e579781
commit
8824ad0df0
1 changed files with 8 additions and 2 deletions
|
@ -171,6 +171,10 @@ You can name your arguments with a flag:
|
||||||
- They can be optional
|
- They can be optional
|
||||||
- Intent is clearer
|
- Intent is clearer
|
||||||
|
|
||||||
|
The `#[clap(short = 'c')]` and `#[clap(long = "name")]` attributes that define
|
||||||
|
the flags are `Arg` methods that are derived from the field name when no value
|
||||||
|
is specified (`#[clap(short)]` and `#[clap(long)]`).
|
||||||
|
|
||||||
[Example:](03_02_option.rs)
|
[Example:](03_02_option.rs)
|
||||||
```console
|
```console
|
||||||
$ 03_02_option_derive --help
|
$ 03_02_option_derive --help
|
||||||
|
@ -207,7 +211,9 @@ name: Some("bob")
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
|
|
||||||
Flags can also be switches that can be on/off:
|
Flags can also be switches that can be on/off. This is enabled via the
|
||||||
|
`#[clap(parse(from_flag)]` attribute though this is implied when the field is a
|
||||||
|
`bool`.
|
||||||
|
|
||||||
[Example:](03_01_flag_bool.rs)
|
[Example:](03_01_flag_bool.rs)
|
||||||
```console
|
```console
|
||||||
|
@ -240,7 +246,7 @@ For more information try --help
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Or counted.
|
Or counted with `#[clap(parse(from_occurrences))]`:
|
||||||
|
|
||||||
[Example:](03_01_flag_count.rs)
|
[Example:](03_01_flag_count.rs)
|
||||||
```console
|
```console
|
||||||
|
|
Loading…
Reference in a new issue