rust 在--help屏幕的末尾添加一条自定义帮助消息,

lvmkulzt  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(107)

使用Rust的Clap crate,我想在帮助屏幕的底部添加一条消息(在所有的标志描述之后)。有没有一种方法可以用clap-derive来实现?

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

字符串
预期产出:

MyProgram ...

  --file FILE  Path to a file

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

fkaflof6

fkaflof61#

您正在寻找after_help属性

#[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

相关问题