add note about using doc comments for help messages (texitoi/structopt#1)

This commit is contained in:
William Yao 2017-07-03 14:26:03 -05:00 committed by Guillaume P
parent 12e88e1ea8
commit a21a01acb2

View file

@ -37,7 +37,7 @@
//! if not specified:
//!
//! - `name`: The binary name displayed in help messages. Defaults
to the crate name given by Cargo.
//! to the crate name given by Cargo.
//! - `version`: Defaults to the crate version given by Cargo.
//! - `author`: Defaults to the crate author name given by Cargo.
//! - `about`: Defaults to the crate description given by Cargo.
@ -77,6 +77,26 @@
//! .default_value("42")
//! ```
//!
//! ## Help messages
//!
//! Help messages for the whole binary or individual arguments can be
//! specified using the `about` attribute on the struct/field, as we've
//! already seen. For convenience, they can also be specified using
//! doc comments. For example:
//!
//! ```ignore
//! #[derive(StructOpt)]
//! #[structopt(name = "foo")]
//! /// The help message that will be displayed when passing `--help`.
//! struct Foo {
//! ...
//! #[structopt(short = "b")]
//! /// The description for the arg that will be displayed when passing `--help`.
//! bar: String
//! ...
//! }
//! ```
//!
//! ## Subcomamnds
//!
//! Some applications, like `git`, support "subcommands;" an extra command that