Crates.io | argue |
lib.rs | argue |
version | 0.1.0 |
source | src |
created_at | 2020-11-24 03:53:11.977748 |
updated_at | 2020-11-24 03:53:11.977748 |
description | Argument parsing library for fun |
homepage | |
repository | https://github.com/cdecompilador/argue.git |
max_upload_size | |
id | 315636 |
size | 11,107 |
Argue is a cli argument parser similar to clap, its just a for fun project, not serious for the moment.
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);
}
Everythins is accepted, just document properly what you do