mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
add note about using doc comments for help messages (texitoi/structopt#1)
This commit is contained in:
parent
12e88e1ea8
commit
a21a01acb2
1 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue