Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: tell about possible literals use for attribute values #195

Merged
merged 1 commit into from
Jun 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@
//! - `author`: Defaults to the crate author name given by Cargo.
//! - `about`: Defaults to the crate description given by Cargo.
//!
//! Methods from `clap::App` that don't take an `&str` can be called by
//! wrapping them in `raw()`, e.g. to activate colored help text:
//! This approach also works for booleans and numbers which can be
//! used as values of the attributes for corresponding `clap::App`
//! methods (e.g. for `fn function(self, bool)` and so on).
//!
//! Methods from `clap::App` that don't take an atomic literal
//! argument (`&str`, `bool` or numbers) can be called by wrapping
//! them in `raw()`, e.g. to activate colored help text:
//!
//! ```
//! #[macro_use]
Expand All @@ -105,14 +110,17 @@
//! # fn main() {}
//! ```
//!
//! Then, each field of the struct not marked as a subcommand corresponds
//! to a `clap::Arg`. As with the struct attributes, every method of
//! `clap::Arg` in the form of `fn function_name(self, &str)` can be used
//! through specifying it as an attribute. The `name` attribute can be used
//! to customize the `Arg::with_name()` call (defaults to the field name in
//! kebab-case).
//! For functions that do not take a `&str` as argument, the attribute can be
//! wrapped in `raw()`, e. g. `raw(aliases = r#"&["alias"]"#, next_line_help = "true")`.
//! Then, each field of the struct not marked as a subcommand
//! corresponds to a `clap::Arg`. As with the struct attributes, every
//! method of `clap::Arg` in the form of `fn function_name(self,
//! &str)`, `fn function_name(self, bool)` or `fn function_name(self,
//! usize)` can be used through specifying it as an attribute with a
//! literal value. The `name` attribute can be used to customize the
//! `Arg::with_name()` call (defaults to the field name in
//! kebab-case). For functions that do not take an atomic literal as
//! argument, the attribute can be wrapped in `raw()`, e. g.
//! `raw(aliases = r#"&["alias"]"#, possible_values = r#"&["fast",
//! "slow"]"#)`.
//!
//! The type of the field gives the kind of argument:
//!
Expand Down