小编Jus*_*ody的帖子

有没有办法让拍手覆盖[-h | --help]标志帮助文本?

我正在关注Rust Clap Package的文档中的示例代码,但找不到有关自动生成的标志[-h和--help]的帮助文本的任何参考.

extern crate clap;

use clap::{App, Arg, SubCommand};

fn main() {
    let matches = App::new("Command One")
        .version("1.0")
        .author("Some Author <the_account@provider.com>")
        .about("Descripción del comando.")
        .arg(Arg::with_name("config")
            .short("c")
            .long("config")
            .value_name("FILE")
            .help("Sets a custom config file")
            .takes_value(true))
        .arg(Arg::with_name("INPUT")
            .help("Sets the input file to use")
            .required(true)
            .index(1))
        .arg(Arg::with_name("v")
            .short("v")
            .multiple(true)
            .help("Sets the level of verbosity"))

        // *** I'm trying this ***
        .arg(Arg::with_name("help")
            .short("h")
            .long("help")
            .help("A new help text."))
        // ***********

        .subcommand(SubCommand::with_name("test")
            .about("controls testing features")
            .version("1.3")
            .author("Someone E. <someone_else@other.com>")
            .arg(Arg::with_name("debug")
                .short("d")
                .help("print debug information …
Run Code Online (Sandbox Code Playgroud)

arguments rust clap

-3
推荐指数
1
解决办法
358
查看次数

标签 统计

arguments ×1

clap ×1

rust ×1