argparse
is a flexible utility for D programming language to parse command line arguments.
Important
Please be aware that current HEAD contains breaking changes comparing to 1.* version.
- Positional arguments:
- Automatic type conversion of the value.
- Required by default, can be marked as optional.
- Named arguments:
- Multiple names are supported, including short (
-v
) and long (--verbose
) ones. - Case-sensitive/-insensitive parsing.
- Bundling of short names (
-vvv
is same as-v -v -v
). - Equals sign is accepted (
-v=debug
,--verbose=debug
). - Automatic type conversion of the value.
- Optional by default, can be marked as required.
- Multiple names are supported, including short (
- Support different types of destination data member:
- Scalar (e.g.,
int
,float
,bool
). - String arguments.
- Enum arguments.
- Array arguments.
- Hash (associative array) arguments.
- Callbacks.
- Scalar (e.g.,
- Different workflows are supported:
- Mixin to inject standard
main
function. - Parsing of known arguments only (returning not recognized ones).
- Enforcing that there are no unknown arguments provided.
- Mixin to inject standard
- Shell completion.
- Options terminator (e.g., parsing up to
--
leaving any argument specified after it). - Arguments groups.
- Subcommands.
- Fully customizable parsing:
- Raw (
string
) data validation (i.e., before parsing). - Custom conversion of argument value (
string
-> anydestination type
). - Validation of parsed data (i.e., after conversion to
destination type
). - Custom action on parsed data (doing something different from storing the parsed value in a member of destination object).
- Raw (
- ANSI colors and styles.
- Built-in reporting of error happened during argument parsing.
- Built-in help generation.
Please find up-to-date documentation here.