1 个不稳定版本

0.1.0 2020年11月24日

#4 in #argument-parsing

自定义许可

9KB
129 代码行数(不含注释)

Argue

Argue 是一个类似于 clap 的命令行参数解析器,它只是一个娱乐项目,目前并非严肃的项目。

示例

use args::{app, Argument, ArgumentType};

/// HOW TO:
///
/// Execute the program this way cargo r --example example0 -- -j 12
/// Also you can try --help, -h, -v, --version that are enabled by default
fn main() {
    // The arguments must be set separeted from the passing to the `arguments`
    // function
    let arguments = &[
        Argument::new(
            // The false is to say than the argument is not mandatory
            ArgumentType::Paired(false), 
            &["-j", "-jthreads"], 
            "Set the number of threads"
        ),
    ];
    
    // Ez to understand i think, pretty close to clap
    let arg_parser = app("Example0")
        .description("An example of the arg parser")
        .version("0.0.1")
        .arguments(arguments)
        .build();
    
    // Get an argument equaled, also work even if -jthreads is passed through
    // the cli
    let n = arg_parser.get("-j").unwrap();
    println!("Number of cores: {}", n);
}

贡献

接受一切贡献,只需正确记录你所做的工作即可

无运行时依赖