Crate clap_help

Source
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:

  1. disable the standard clap help printer with disable_help_flag = true
  2. add your own help flag
  3. 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