[go: up one dir, main page]

greeter

Parse/build command lines. Supports both Unix and DOS (maybe).
https://github.com/fal-works/greeter/

To install, run:

haxelib install greeter 0.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

greeter

Parse/build command lines. Both Unix and DOS (maybe).

Overview

  • A single command line is represented by a CommandLine instance.
  • Use Cli for parsing any string array (like Sys.args()) and converting them to CommandLine.
  • There are two Cli instances: Cli.unix and Cli.dos. And Cli.current is one of these two, depending on your current system.
  • For applying any user-defined rules when parsing, create an OptionParseRules instance and pass it to Cli.
  • Any CommandLine can be formatted for either Cli, but throws error if it contains invalid syntax for the selected Cli.

Caveats

  • Not yet very well tested.
  • Quite unstable!

Current Limitations

  • Just single command lines. Does not support pipelines, redirection, stdin etc.
  • No special handling of sub-command names. They are parsed in the same way as any other argument without switch character.
  • Cannot parse/build multiple options unified (e.g. -ab instead of -a -b).
  • Requires space before each option, while some systems do not always require (e.g. DIR/Q/O)
  • Maybe more!

Usage Example

import greeter.*;
final inputRules = OptionParseRules.from([
	"--myOption" => [Space], // accepts a space-separated argument
	"--myFlag" => [] // no argument
]);

final cli = Cli.current; // Either Unix or DOS
final args = cli.parsePassedArguments(inputRules); // Parse args passed via Sys.args()

final summary = args.summary();
Sys.println(summary.toString());

If the arguments below is passed in the command line:

--myOption myOptionValue --myFlag myValue

Then the result is:

command values:
  myValue
options:
  --myOption myOptionValue
  --myFlag

Dependencies

See also: FAL Haxe libraries

Contributors
fal-works
Version
0.1.0
Published
5 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