4 releases
0.2.2 | Sep 18, 2024 |
---|---|
0.2.1 | Sep 15, 2024 |
0.2.0 | Sep 14, 2024 |
0.1.0 | Sep 14, 2024 |
#1 in #abs
26 downloads per month
9KB
197 lines
abs-cli
Lightweight CLI parser in Rust.
examples
use abs_cli::CLI;
fn main() {
let mut program = CLI::new();
program
.name("My Program")
.version("1.0.0")
.description("My super cool cli program")
.option("-l, --ls", "list the directory")
.arg("run", "run <file>", "run the file");
program.parse();
if let Some(ls_values) = program.get("--ls") {
println!("Option --ls provided with value: {:?}", ls_values);
}
if let Some(run_values) = program.get("run") {
println!("Argument run provided with value: {:?}", run_values);
}
}
If command --ls
was passed, Some
value will be returned. If there is a value after --ls
, for example: --ls hello
, value will be: hello
.
Library has built-in help (--help
, -h
) and version (--version
, -v
) commands.
Dependencies
~15KB