【问题标题】:How do I use Clap to parse filenames?如何使用 Clap 解析文件名?
【发布时间】:2021-04-28 19:35:26
【问题描述】:

我知道了:

let args: Vec::<String> = std::env::args().collect();
let matches = App::new("Rust grader")
                    .author("Arkadiusz Bulski <arek.bulski@gmail.com>")
                    .arg(Arg::with_name("noprofile")
                            .long("noprofile")
                            .takes_value(false)
                            .help("Disable profiling, save time"))
                    .get_matches();
let config = matches.value_of("noprofile");

还有一个用法:./binary-runner --noprofile -- tsp-arekbulski-*.rs

如何让这个拍手应用程序识别文件名?

错误:

error: Found argument 'tsp-arekbulski-01-trivial.rs' which wasn't expected, or isn't valid in this context

USAGE:
    binary-runner --noprofile

【问题讨论】:

    标签: rust command-line-arguments clap


    【解决方案1】:

    解决了:

    let matches = App::new("Rust runner")
                        .author("Arkadiusz Bulski <arek.bulski@gmail.com>")
                        .arg(Arg::with_name("sources")
                                .multiple(true)
                                .help("Use this to pass argfilenames"))
                        .get_matches();
    

    【讨论】:

      猜你喜欢
      • 2022-12-20
      • 1970-01-01
      • 1970-01-01
      • 2010-11-26
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 2010-09-08
      • 1970-01-01
      相关资源
      最近更新 更多