argd ~master
A lightweight, class-based argument and subcommand parsing system for D. Features nested commands, automated help, and flexible argument validation.
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:
This package provides sub packages which can be used individually:
argd:basic - Basic example of argd usage
argd
argd is a lightweight, class-based argument and command parsing system for the D programming language. It allows for easy creation of complex command-line interfaces with nested subcommands, automated help generation, and argument validation.
Features
- Nested Subcommands: Create hierarchical CLI tools (like
gitordub). - Automated Help: Automatically generates usage instructions and subcommand/option lists.
- Argument Validation: Specify expected argument counts and collection types.
- Option Handling: Simple registration and retrieval of long and short-form options.
- Cross-Platform: Built using standard D libraries (
std.*).
Installation
Add argd as a dependency in your dub.json:
"dependencies": {
"argd": "~>0.0.1"
}
Quick Start
import argd;
import std.stdio;
class GreetCommand : Command {
this() {
super("greet");
description = "Greets a person";
usage = "<name>";
argCount = 1;
argCollType = ArgCollectionType.exact;
addOption("--formality", "-f", "Use formal greeting");
}
override protected CommandResult onExecute(string[] args, bool verbose, bool quiet) {
string name = args[0];
bool formal = hasOption("--formality", "-f");
if (formal) {
writeln("Greetings, ", name, ".");
} else {
writeln("Hello, ", name, "!");
}
return CommandResult.ok();
}
}
void main(string[] args) {
auto root = new GreetCommand();
auto result = root.handle(args[1 .. $]);
// Check if there is a message to display (like help or errors)
if (result.message.length > 0) {
if (result.success) {
writeln(result.message);
} else {
stderr.writeln(result.message);
}
}
}
Examples
Check out the examples/ directory for a complete demonstration of a multi-command CLI. You can run it directly using Dub:
dub run :basic -- greet "World" --formality
License
This project is licensed under the MIT License.
- ~master released 2 days ago
- kerem3338/argd
- MIT
- Copyright © 2026, Kerem ATA (zoda)
- Authors:
- Sub packages:
- argd:basic
- Dependencies:
- none
- Versions:
-
Show all 2 versions0.0.1 2026-Mar-28 ~master 2026-Mar-28 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
0 downloads total
-
- Score:
- 0.0
- Short URL:
- argd.dub.pm