Skip to content

Commit

Permalink
Merge pull request #3771 from epage/ref
Browse files Browse the repository at this point in the history
docs(derive): Make raw attribute more discoverable
  • Loading branch information
epage committed May 31, 2022
2 parents 54a1530 + b39d3d4 commit e43bd1f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions examples/derive_ref/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ attributes.
These correspond to a `clap::Command` which is used for both top-level parsers and
when defining subcommands.

**Raw attributes:** Any [`Command` method](https://docs.rs/clap/latest/clap/type.Command.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(arg_required_else_help(true))]` would translate to `cmd.arg_required_else_help(true)`

**Magic attributes:**
- `name = <expr>`: `clap::Command::name`
- When not present: [crate `name`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-name-field) (`Parser` container), variant name (`Subcommand` variant)
Expand Down Expand Up @@ -163,13 +166,13 @@ And for `Subcommand` variants:
- `external_subcommand`: `clap::Command::allow_external_subcommand(true)`
- Variant must be either `Variant(Vec<String>)` or `Variant(Vec<OsString>)`

**Raw attributes:** Any [`Command` method](https://docs.rs/clap/latest/clap/type.Command.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(arg_required_else_help(true))]` would translate to `cmd.arg_required_else_help(true)`

### Arg Attributes

These correspond to a `clap::Arg`.

**Raw attributes:** Any [`Arg` method](https://docs.rs/clap/latest/clap/struct.Arg.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(max_values(3))]` would translate to `arg.max_values(3)`

**Magic attributes**:
- `name = <expr>`: `clap::Arg::new`
- When not present: case-converted field name is used
Expand Down Expand Up @@ -216,9 +219,6 @@ These correspond to a `clap::Arg`.
- Requires `std::convert::Into<OsString>` or `#[clap(arg_enum)]`
- Without `<expr>`, relies on `Default::default()`

**Raw attributes:** Any [`Arg` method](https://docs.rs/clap/latest/clap/struct.Arg.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(max_values(3))]` would translate to `arg.max_values(3)`

### Arg Enum Attributes

- `rename_all = <expr>`: Override default field / variant name case conversion for `PossibleValue::new`
Expand All @@ -229,15 +229,15 @@ These correspond to a `clap::Arg`.

These correspond to a `clap::PossibleValue`.

**Raw attributes:** Any [`PossibleValue` method](https://docs.rs/clap/latest/clap/struct.PossibleValue.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(alias("foo"))]` would translate to `pv.alias("foo")`

**Magic attributes**:
- `name = <expr>`: `clap::PossibleValue::new`
- When not present: case-converted field name is used
- `help = <expr>`: `clap::PossibleValue::help`
- When not present: [Doc comment summary](#doc-comments)

**Raw attributes:** Any [`PossibleValue` method](https://docs.rs/clap/latest/clap/struct.PossibleValue.html) can also be used as an attribute, see [Terminology](#terminology) for syntax.
- e.g. `#[clap(alias("foo"))]` would translate to `pv.alias("foo")`

## Arg Types

`clap` assumes some intent based on the type used:
Expand Down

0 comments on commit e43bd1f

Please sign in to comment.