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
- Parsing of
short options(Values set with--which default is false and set to true by being used.) - Parsing of
long options(Values mentioned after-which have their value(as a string) followed) - Parsing of
non options(Single Values parameters without any prefix ) - Parsing of
sub commands(which only one can be used and all following arguments are related to) - Returning results instead of throwing unfinished error messages
- Simple creation of parser
- Ability to create parser as constant or static variable (at compile time)
- Ability to give a list of arguments (not using args from std::env::args())
- Ability to provide default values
- Ability to make Argument or subcommand required
- Cache the result of parsing the cli arguments to improve performance slightly
- fulfill common patters, like described in this specification
Installation
Add arg_parse = "0.3.0" to your cargo dependencies (cargo.toml).
[]
= "0.3.0"
Example
Prints the Options which are found or parsing errors. Arguments:
- LongOption:
hellowithout any further arguments - ShortOption:
bwith two arguments - ShortOption:
awithout any arguments
use ArgParser;
use config;
//List of all available long options
const LONG_OPTIONS: &'static = &;
//List of all available short options
const SHORT_OPTIONS: &'static = &;
const NON_OPTIONS: &'static = &;
//Create the root command which is the program itself basically
const PARSER_ROOT_CMD: Config = from;
//Create the parser from the root command
static PARSER: ArgParser = from;