simple-cli-parser 0.1.1

A crate for parsing commands and arguemnts passed to the console.
Documentation
  • Coverage
  • 100%
    14 out of 14 items documented14 out of 14 items with examples
  • Size
  • Source code size: 18.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 700.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • rafesholler/cli-parser-rust
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rafesholler

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"));
}