mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
Add doc on colored help (#40)
Added a note about `clap::App`'s _raw methods, and an example specifically about colored help text.
This commit is contained in:
parent
374f9080a8
commit
cc6dfd2e54
1 changed files with 26 additions and 0 deletions
|
@ -42,6 +42,32 @@
|
|||
//! - `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
|
||||
//! adding _raw to their name, e.g. to activate colored help text:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! extern crate clap;
|
||||
//! extern crate structopt;
|
||||
//! #[macro_use]
|
||||
//! extern crate structopt_derive;
|
||||
//!
|
||||
//! use structopt::StructOpt;
|
||||
//!
|
||||
//! #[derive(StructOpt, Debug)]
|
||||
//! #[structopt(setting_raw = "clap::AppSettings::ColoredHelp")]
|
||||
//! struct Opt {
|
||||
//! #[structopt(short = "s")]
|
||||
//! speed: bool,
|
||||
//! #[structopt(short = "d")]
|
||||
//! debug: bool,
|
||||
//! }
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let opt = Opt::from_args();
|
||||
//! println!("{:?}", opt);
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! 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
|
||||
|
|
Loading…
Reference in a new issue