abs-cli

Crates.ioabs-cli
lib.rsabs-cli
version0.2.2
sourcesrc
created_at2024-09-14 04:26:04.166444
updated_at2024-09-18 10:14:37.370743
descriptionCLI parsing library
homepage
repository
max_upload_size
id1374455
size9,302
(cf-x)

documentation

README

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.

Commit count: 0

cargo fmt