Simple Argument Parser

A simple and robust command-line argument parsing library for Rust.
This library provides a builder pattern API to define arguments and a parser to process them from the command line. The parsed arguments can be converted to any type that implements FromStr.
Installation
Add this line to your Cargo.toml file:
[dependencies]
sarpa = "0.1.2"
Quick Start
Here is a complete example of how to use the library in src/main.rs:
use std::env;
use sarpa::{ArgParseError, Parser};
fn main() {
let mut parser = Parser::new();
parser.add_flag("verbose")
.with_short_name('v')
.with_help("Enable verbose output");
parser.add_option("output")
.with_short_name('o')
.with_help("Specify an output file")
.required();
parser.add_positional("input")
.with_help("The input file to process");
let args = env::args();
let results = parser.parse(args);
match results {
Ok(parsed_args) => {
if parsed_args.flags.contains("verbose") {
println!("Verbose mode is enabled!");
}
let output_file = parsed_args.options.get("output").unwrap();
println!("Output file: {}", output_file);
}
Err(e) => {
match e {
ArgParseError::HelpRequested => {
println!("{}", parser.generate_help());
}
_ => {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}
}
}
}