Crates.io | abs-cli |
lib.rs | abs-cli |
version | 0.2.2 |
source | src |
created_at | 2024-09-14 04:26:04.166444 |
updated_at | 2024-09-18 10:14:37.370743 |
description | CLI parsing library |
homepage | |
repository | |
max_upload_size | |
id | 1374455 |
size | 9,302 |
Lightweight CLI parser in Rust.
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.