simple-cli-parser

Crates.iosimple-cli-parser
lib.rssimple-cli-parser
version0.1.1
created_at2025-03-29 20:09:39.412878+00
updated_at2025-03-29 20:18:15.791623+00
descriptionA crate for parsing commands and arguemnts passed to the console.
homepage
repositoryhttps://github.com/rafesholler/cli-parser-rust
max_upload_size
id1611646
size19,187
Rafe Sholler (rafesholler)

documentation

README

Simple_CLI_Parser

A crate for parsing commands and arguemnts passed to the console.

This can parse commands from std::env::args() with various arguments. It currently supports optional arguments (both short and long) as well as required parameters. Note that order is important for required parameters, but not for optional arguments.

Installation

Run the following Cargo command in your project directory:

cargo add simple-cli-parser

Or add the following line to your Cargo.toml:

simple-cli-parser = "0.1.0"

Example Usage

use simple_cli_parser::*;

fn main() {
    let parser = Parser::new();
    let arg = Arg::new().param("num");
    parser.add_arg(arg);

    let mut args = std::env::args();
    args.next();

    let hashmap = parser.parse(&mut args).unwrap();
    println!("{}", hashmap.get("num"));
}
Commit count: 16

cargo fmt