arg_parse for rust

Disclaimer

The interface for developer is work in progress. So expect minor and major changes when updating until v1.0

Description

arg_parse is a tool to simplify the processing of command line arguments. It doesn't have any dependencies and the initialization is done at compile time.

Features & Goals

Installation

Add arg_parse = "0.2.3" to your cargo dependencies (cargo.toml). toml [dependencies] arg_parse = "0.2.3"

# Example Prints the Options which are found or parsing errors.
Arguments: - LongOption: hello without any further arguments - ShortOption: b with two arguments - ShortOption: a without any arguments ```rust use argparse::ArgParser; use argparse::config;

//List of all available long options const LONGOPTIONS: &'static [config::LongOption] = &[ //Define a long option called hello without parameters config::LongOption{name: "hello", valuecount: 0} ]; //List of all available short options const SHORTOPTIONS: &'static [config::ShortOption] = &[ //Define a short option called b with two parameters config::ShortOption{name:'b', valuecount: 2}, //Define a short option called a without parameters config::ShortOption{name:'a', value_count: 0} ];

//Create the root command which is the program itself basically const PARSERROOTCMD: config::Cmd = config::Cmd::from(SHORTOPTIONS, LONGOPTIONS, &[]);

//Create the parser from the root command static PARSER: ArgParser = ArgParser::from(PARSERROOTCMD);

fn main() { let rootcmd = PARSER.parse(); //Parse the command line arguments match rootcmd { Ok(result) => println!("Result: {:?}", result), //Print result Err(error) => println!("ERROR: {:?}", error) //Print errors if occur } } ```

Links:

Github Repo
Crates.io
Rust Docs