argparse 2.0.0
Parser for command line arguments
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Parser for command line arguments
argparse
is a flexible utility for D programming language to parse command line arguments.
[!WARNING] :warning: Version 2. contains breaking changes comparing to 1. - see change log for details
:warning: This includes changes in documentation - documentation for 1.* version is here
Features
- 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.
Documentation
Please find up-to-date documentation here.
- 2.0.0 released 13 days ago
- andrey-zherikov/argparse
- BSL-1.0
- Copyright © 2021, Andrey Zherikov
- Authors:
- Dependencies:
- none
- Versions:
-
2.0.0 2025-Sep-02 2.0.0-rc2 2025-Jul-05 2.0.0-rc1 2025-Jul-01 1.4.1 2025-Feb-18 1.4.0 2024-Oct-31 - Download Stats:
-
-
0 downloads today
-
14 downloads this week
-
159 downloads this month
-
3856 downloads total
-
- Score:
- 2.7
- Short URL:
- argparse.dub.pm