[英]How to provide multiple line help message with Clap?
有沒有辦法讓我們在 clap 的幫助信息中換行?
我嘗試了多行注釋,還嘗試在混合中插入\n
。 但兩者都不起作用。
#[derive(Parser, Debug)]
#[clap(author, version, about)]
struct Args {
/// The input filename.\n
/// Hello world!
#[clap(short, long, value_parser)]
input: String,
}
輸出:
USAGE:
ascii_tree --input <INPUT>
OPTIONS:
-h, --help Print help information
-i, --input <INPUT> The input filename.\n Hello world!
-V, --version Print version information
有沒有實現以下目標?
USAGE:
ascii_tree --input <INPUT>
OPTIONS:
-h, --help Print help information
-i, --input <INPUT> The input filename.
Hello world!
-V, --version Print version information
我知道兩種選擇。 使第二行僅包含///
,或使用verbatim_doc_comment
:
#[derive(Parser, Debug)]
struct Args {
/// Name of the person to greet
///
/// Has a multi-line help.
#[clap(short, long)]
name: String,
/// Number of times to greet
/// Use the verbatim arg
#[clap(short, long, verbatim_doc_comment)]
count: u8,
}
您可以添加verbatim_doc_comment
選項:
#[derive(Parser, Debug)]
#[clap(author, version, about)]
struct Args {
/// The input filename.
/// Hello world!
#[clap(short, long, value_parser, verbatim_doc_comment)]
input: String,
}
USAGE:
ascii_tree --input <INPUT>
OPTIONS:
-h, --help Print help information
-i, --input <INPUT> The input filename.
Hello world!
-V, --version Print version information
似乎沒有它,Rust 只能通過雙換行符識別段落中斷。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.