rparse 0.1.1

Simple human-readable command-line parser
Documentation
  • Coverage
  • 0%
    0 out of 12 items documented0 out of 5 items with examples
  • Size
  • Source code size: 17.59 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Traffic4269

rparse

Description

Simple human-readable command-line argument parser.

Usage

rparse allows for users to build their own command-line arguments in the form of Argument structs in a vector array.

These are then passed alongside std::env::args() to a parsing module to check and fetch command-line arguments.

Example

use rparse::{parser, builder::Argument};

// Build arguments into a vector array
fn build_arguments() -> Vec<Argument> {
    let args: Vec<Argument> = vec![
        Argument::new("feeds", "--feed", "-f"),
        Argument::new("file", "--file", "-i"),
    ];
    return args;
}

fn main() {

    // Build arguments
    let args: Vec<Argument> = build_arguments();

    // Fetch arguments passed to the program
    let passed = std::env::args();

    // Parse command-line arguments
    let returned = parser::parse(args, passed).args;
    println!("{:?}", returned["feeds"]);
}

Notes

parser::parse(args, passed) returns a ParsedArguments struct. This contains a HashMap of arguments found on the command line, referenced as args. To then access this, call the key from the HashMap: parser::parse(args, passed).args["key"].