args
A command line and config file parser for DLang
Quick Example
import args : Arg, Optional, parseArgsWithConfigFile, printArgsHelp;
static struct MyOptions {
@Arg("the input file", Optional.yes) string inputFilename;
@Arg("test values", 't') int[] testValues;
@Arg("Enable feature") bool enableFeature;
}
MyOptions getOptions(ref string[] args) {
MyOptions options;
bool helpWanted = parseArgsWithConfigFile(options, args);
if (helpWanted) {
printArgsHelp(options, "A text explaining the program");
}
return options;
}
void main(string[] args) {
const options = getOptions(args); // or args.dup to keep the original args
// use options here....
}
This gives:
❯ ./quick_example --help
A text explaining the program
--inputFilename Type: dchar[] default: Help: the input file
-t --testValues Type: int[] default: [] Help: test values
--enableFeature Type: bool default: false Help: Enable feature