parcl

Parse command line arguments and generate CLI help text with magic.
https://codeberg.org/sharpcdf/parcl

To install, run:

haxelib install parcl 0.1.1 

See using Haxelib in Haxelib documentation for more information.

README.md

parcl

PArsing ARguments for the Command Line

A simple, lenient command-line argument parsing library and help text generator for Haxe and its Sys-compatible targets Documentation;

import parcl.Parcl;

class Main {
    
    static public function main() {
        var quietmode = false;
        var lang: String;

        var cli = new Parcl("PARCL", "MAKE CLIS", "MADE BY SHARPCDF/KESPA");
        cli.addArg(HelpArgument.Flag("quiet", "suppresses the log"));
        cli.addArg(HelpArgument.Option("language", "what language do you use?"));
        cli.addHelpFlags();
        cli.checkResults();
        
        for (arg in cli.results) {
            switch (arg) {
                case ResultArg.Flag(v):
                    if (v.name == "quiet") {
                        quietmode = true;
                    }
                default:
                    continue;
            }
        }
        if (cli.hasName("language") && !quietmode) {
            var lang = cli.value("language");
            Sys.println('using $lang' + (lang.toLowerCase() != "haxe" ? ", maybe use Haxe next time!" : ", good choice!"));
        }
    }
}

Result

❯ neko main.n
PARCL
   MAKE CLIS

Flags:
      -quiet                                                                          suppresses the log
      -h                                                                              Displays this help
      -help                                                                           Displays this help

Options:
      --language=STRING                                                               what language do you use?


MADE BY SHARPCDF/KESPA
Contributors
kespa
Version
0.1.1
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub