A tiny command line argument parser with automatic help generation, and argument validation.
- Inputs are categorized as
commands,options, andva args. - Options are defined with the
-or--prefixes. - These can hold values representing booleans, numbers and text values, (stored internally as bool, f64 and Strings).
- Boolean short name options can be set as groups. E.g.:
-abc - Arguments with values are strictly defined by using the equal sign
=, i.e.--arg=value. - Commands and va args have no dash prefix. First argument of such kind is stored as the command, and the rest into a va_args "bucket", which can be retrived with
get_va_args(). - Help sections such as description, usage, and examples can be redefined if needed using the
provided functions:
define_help_...(). - The help call (-h --help) is hard coded during argument parsing.
Example
use ExitCode;
use *;
Generated Help
>demo_program --help
A demo program for TinyArgs
Help:
Usage: demo [OPTIONS] [COMMAND] [ARGS]...
Commands:
list List args
version Display version
Options:
-c, --context=<context> Context lines [Default: 4]
-h, --help Display this help message
--name=<name> A name of something [Default: test]
-v, --verbose Verbose mode
Examples:
demo --name=test some/path/ - Sets some values