arg_parse for rust
Description
arg_pare 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
- Parsing of
flags
(Values set with--
which default is false and set to true by being used.) - Parsing of
parameters
(Values mentioned after-
which have their value(as a string) followed) - 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 of 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
- Easy macro or function to configure the parser
- Split Config and Results into different features which can be enabled or disabled in the cargo.toml
Installation
Add arg_parse = "0.1.0"
to your cargo dependencies (cargo.toml
).
[]
= "0.1.0"
Example
Prints if the flag --a
is provided and the parameter provided under -b
use ArgParser;
use config;
// Define all Arguments of the program itself/root command (compile time)
const ARGS: &'static = &;
// Define the Root Command, without any possible sub commands (compile time)
const PARSER_ROOT_CMD: Cmd = from;
// Create the Parser in static memory, available everywhere (Created at compile time)
static PARSER: ArgParser = from;