All Projects → jasonwhite → darg

jasonwhite / darg

Licence: MIT license
Robust command line argument parsing for D.

Programming Languages

d
599 projects

Projects that are alternatives of or similar to darg

structopt-toml
An default value loader from TOML for structopt
Stars: ✭ 23 (-37.84%)
Mutual labels:  argument-parsing
Clipp
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation
Stars: ✭ 687 (+1756.76%)
Mutual labels:  argument-parsing
Argparse.jl
Package for parsing command-line arguments to Julia programs.
Stars: ✭ 131 (+254.05%)
Mutual labels:  argument-parsing
AnyOption
C/C++ Command line and resource file option parsing
Stars: ✭ 83 (+124.32%)
Mutual labels:  argument-parsing
Argparse
Command-line arguments parsing library.
Stars: ✭ 362 (+878.38%)
Mutual labels:  argument-parsing
Nclap
NClap is a .NET library for parsing command-line arguments and building interactive command shells. It's driven by a declarative attribute syntax, and easy to extend.
Stars: ✭ 51 (+37.84%)
Mutual labels:  argument-parsing
typed-argument-parser
Typed argument parser for Python
Stars: ✭ 259 (+600%)
Mutual labels:  argument-parsing
Argumentparser
Faster, easier, more declarative parsing of command line arguments in Objective-C/Foundation.
Stars: ✭ 251 (+578.38%)
Mutual labels:  argument-parsing
Clap
Create your command-line parser, with all of the bells and whistles, declaratively or procedurally.
Stars: ✭ 7,174 (+19289.19%)
Mutual labels:  argument-parsing
Yaap
Yet Another (Swift) Argument Parser
Stars: ✭ 124 (+235.14%)
Mutual labels:  argument-parsing
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+8781.08%)
Mutual labels:  argument-parsing
Thunder
⚡ Zero-boilerplate commandline argument parsing in Rust
Stars: ✭ 358 (+867.57%)
Mutual labels:  argument-parsing
Go Arg
Struct-based argument parsing in Go
Stars: ✭ 1,068 (+2786.49%)
Mutual labels:  argument-parsing
argen
Generate argument parsing logic in C from a simple config
Stars: ✭ 14 (-62.16%)
Mutual labels:  argument-parsing
Lyra
A simple to use, composable, command line parser for C++ 11 and beyond
Stars: ✭ 238 (+543.24%)
Mutual labels:  argument-parsing
yargs-interactive
Interactive support for yargs
Stars: ✭ 40 (+8.11%)
Mutual labels:  argument-parsing
Argbash
Bash argument parsing code generator
Stars: ✭ 873 (+2259.46%)
Mutual labels:  argument-parsing
argparse
Parser for command-line arguments
Stars: ✭ 24 (-35.14%)
Mutual labels:  argument-parsing
Case App
Type-level & seamless command-line argument parsing for Scala
Stars: ✭ 244 (+559.46%)
Mutual labels:  argument-parsing
Clikt
Multiplatform command line interface parsing for Kotlin
Stars: ✭ 1,658 (+4381.08%)
Mutual labels:  argument-parsing

D Argument Parser Build Status

Better command line argument parsing using D's powerful compile-time code generation facilities.

Note: This is a stable library, but it is no longer maintained. If you'd like to help out with maintanence please make an issue letting me know!

Example

import std.stdio;
import darg;

struct Options
{
    @Option("help", "h")
    @Help("Prints this help.")
    OptionFlag help;

    @Option("threads", "t")
    @Help("Number of threads to use.")
    size_t threads;

    @Argument("file", Multiplicity.zeroOrMore)
    @Help("Input files")
    string[] files;
}

// Generate the usage and help string at compile time.
immutable usage = usageString!Options("example");
immutable help = helpString!Options;

int main(string[] args)
{
    Options options;

    try
    {
        options = parseArgs!Options(args[1 .. $]);
    }
    catch (ArgParseError e)
    {
        writeln(e.msg);
        writeln(usage);
        return 1;
    }
    catch (ArgParseHelp e)
    {
        // Help was requested
        writeln(usage);
        write(help);
        return 0;
    }

    foreach (f; options.files)
    {
        // Use files
    }

    return 0;
}
$ ./example --help
Usage: example [--help] [--threads=<ulong>] [file...]

Positional arguments:
 file            Input files

Optional arguments:
 --help, -h      Prints this help.
 --threads, -t <ulong>
                 Number of threads to use.

$ ./example --foobar
Unknown option '--foobar'
Usage: program [--help] [--threads=<ulong>] [file...]

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].