Expand description
clap-help is an alternate help printer for applications using clap.
clap-help displays arguments in a more readable format, in a width-aware table and lets you customize the content and style.
Minimal usage:
- disable the standard clap help printer with
disable_help_flag = true
- add your own help flag
- call
clap_help::print_help
in the handler for your help flag
use clap::{CommandFactory, Parser, ValueEnum};
use clap_help::Printer;
#[derive(Parser, Debug)]
#[command(name="my_prog", author, version, about, disable_help_flag = true)]
struct Args {
/// Print help
#[arg(long)]
help: bool,
// other arguments
}
fn main() {
let args = Args::parse();
if args.help {
Printer::new(Args::command()).print_help();
return;
}
// rest of the program
}
The examples directory shows how to customize the help.
Structs§
- Printer
- An object which you can configure to print the help of a command
Statics§
- TEMPLATES
- Keys used to enable/disable/change templates
- TEMPLATE_
AUTHOR - Default template for the “author” section
- TEMPLATE_
OPTIONS - Default template for the “options” section
- TEMPLATE_
OPTIONS_ MERGED_ VALUE - a template for the “options” section with the value merged to short and long
- TEMPLATE_
POSITIONALS - Default template for the “positionals” section
- TEMPLATE_
TITLE - Default template for the “title” section
- TEMPLATE_
USAGE - Default template for the “usage” section