Add a custom help message at the end of --help screen with clap-derive

142 Views Asked by At

Using Rust's Clap crate, I would like to add a message at the bottom of the help screen (after all the flag description). Is there a way to do it with the clap-derive?

#[derive(Parser, Debug, Default)]
#[command(about, version)]
pub struct Args {
    /// Path to a file.
    #[arg(short, long)]
    pub file: Option<PathBuf>,
}

Expected output:

MyProgram ...

  --file FILE  Path to a file

Some very long explanation that should be printed at the end of the help screen
1

There are 1 best solutions below

0
On BEST ANSWER

You're looking for the after_help property

#[derive(Parser, Debug, Default)]
#[command(about, version, after_help = 
    "Some very long explanation that should be printed at the end of the help screen"
)]
pub struct Args {
    /// Path to a file.
    #[arg(short, long)]
    pub file: Option<PathBuf>,
}

playground