cli-parser 0.1.0

Lightweight API for parsing CLI arguments
Documentation
  • Coverage
  • 35.71%
    5 out of 14 items documented1 out of 4 items with examples
  • Size
  • Source code size: 6.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • gzarpapis/cli-parser
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gzarpapis

cli-parser

Introduction

This library provides a very light-weight API, for a singular purpose: Collect the command line arguments in 3 std structures based on the number of dashes prefixed.

  • Vector $\leftarrow$ 0 dashes $\leftarrow$ Positional arguments (values only).
  • HashSet $\leftarrow$ 1 dash $\leftarrow$ Flags (keys only).
  • HashMap $\leftarrow$ 2 dashes $\leftarrow$ Key - value pairs.

Syntax example:

./my_program --debug_level=2 -verb path/to/file 

These arguments are classified as:

  • Positional:
    1. ./my_program
    2. path/to/file
  • Flags:
    1. verb
  • Pairs:
    1. debug_level with value 2

Usage

Just initialize the CLIParser struct and you are good to go.

use cliparser::CLIParser;


fn main() {

	// Initialize parser
	let parser = CLIParser::new().init().unwrap();
	
	// Extract parsed data structures
	let posit_arguments = parser.posits.clone(); // Vector
	let flags = parser.flags.clone(); // HashSet
	let pairs = parser.pairs.clone(); // HashMap
}