pub const HELP_TEMPLATE: &str = r"{about-section}
{usage-heading} {usage}
{all-args}{tab}
{name}: {version}
Author: {author-with-newline}
";Expand description
Custom help template for displaying command-line usage information
This template modifies the default template provided by Clap to include additional information and customize the layout of the help message.
Differences from the default template:
- Includes the application version and author information at the end
Apply like this:
use clap::Parser;
#[derive(Parser, Debug, Clone, PartialEq, Eq, Hash)]
#[command(help_template = HELP_TEMPLATE, author, version)]
pub struct MyArgs {
/// show more details
#[arg(short, long)]
pub verbose: bool,
}§Example
Don’t forget to set authors in your Cargo.toml!
$ cargo run -- -h
about: short
Usage: aaa [OPTIONS]
Options:
-v, --verbose show more details
-h, --help Print help (see more with '--help')
-V, --version Print version
aaa: 0.1.0
Author: Christoph J. Scherr <software@cscherr.de>