clap/clap_derive/examples
Ed Page d840d5650e fix(derive)!: Rename Clap to Parser.
Before #2005, `Clap` was a special trait that derived all clap traits it
detected were relevant (including an enum getting both `ArgEnum`,
`Clap`, and `Subcommand`).  Now, we have elevated `Clap`, `Args`,
`Subcommand`, and `ArgEnum` to be user facing but the name `Clap` isn't
very descriptive.

This also helps further clarify the relationships so a crate providing
an item to be `#[clap(flatten)]` or `#[clap(subcommand)]` is more likely
to choose the needed trait to derive.

Also, my proposed fix fo #2785 includes making `App` attributes almost
exclusively for `Clap`.  Clarifying the names/roles will help
communicate this.

For prior discussion, see #2583
2021-10-09 20:12:03 -05:00
..
after_help.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
arg_enum.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
at_least_two.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
basic.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
deny_missing_docs.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
doc_comments.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
enum_tuple.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
env.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
example.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
flatten.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
from_crate.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
git.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
group.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
keyvalue.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
negative_flag.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
README.md Add examples for using value_hint with clap_derive 2020-10-10 00:11:44 +03:00
rename_all.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
skip.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
subcommand_aliases.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
true_or_false.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00
value_hints_derive.rs fix(derive)!: Rename Clap to Parser. 2021-10-09 20:12:03 -05:00

Collection of examples "how to use clap_derive"

Help on the bottom

How to append a postscript to the help message generated.

Arg Enum

How to use ArgEnum

At least N

How to require presence of at least N values, like val1 val2 ... valN ... valM.

Basic

A basic example how to use clap_derive.

Deny missing docs

This is not an example but a test, it should be moved to tests folder as soon as this is fixed (if ever).

Doc comments

How to use doc comments in place of help/long_help.

Arguments of subcommands in separate struct

How to extract subcommands' args into external structs.

Environment variables

How to use environment variable fallback an how it interacts with default_value.

Advanced

Somewhat complex example of usage of clap_derive.

Flatten

How to use #[clap(flatten)]

Git

Pseudo-git example, shows how to use subcommands and how to document them.

Groups

Using clap::Arg::group with clap.

key=value pairs

How to parse key=value pairs.

--no-* flags

How to add no-thing flag which is true by default and false if passed.

Rename all

How #[clap(rename_all)] works.

Skip

How to use #[clap(skip)].

Aliases

How to use aliases

true or false

How to express ""true" or "false" argument.

Author, description, and version from Cargo.toml

How to derive the author, description, and version from Cargo.toml

Value hints for shell completion

How to provide ValueHint attributes and generate shell completion files.