Skip to content

v1.3.3

Choose a tag to compare

@malyjacob malyjacob released this 22 Aug 16:45
· 23 commits to main since this release

enable a break-through new way to build a command line program intuitively like this sample code or the following code:

module examples.strutil;

import std.stdio;
import std.string;
import cmdline;

struct StrutilResult {
    mixin DESC!("CLI to some string utilities");
    mixin VERSION!("0.0.1");
    JoinResult* joinSub;
    SplitResult* splitSub;
}

struct SplitResult {
    mixin DESC!("Split a string into substrings and display as an array.");
    ArgVal!string str;
    mixin DESC!(str, "string to split");
    OptVal!(string, "-s <char>") separator;
    mixin DESC!(separator, "separator character");
    mixin DEFAULT!(separator, ",");

    void action() {
        writeln(split(str.get, separator.get));
    }
}

struct JoinResult {
    mixin DESC!("Join the command-arguments into a single string.");
    ArgVal!(string[]) strs;
    mixin DESC!(strs, "one or more string");
    OptVal!(string, "-s <char>") separator;
    mixin DESC!(separator, "separator character");
    mixin DEFAULT!(separator, ",");

    void action() {
        writeln(strs.get.join(separator.get));
    }
}

void main(in string[] argv) {
    argv.run!StrutilResult;
}

the details you can see are in sub-module cmdline.ext