Argon: an alternative parser for command-line arguments

Markus Laker via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Mar 3 12:55:05 PST 2016


On Thursday, 3 March 2016 at 15:08:37 UTC, Jacob Carlborg wrote:
> Does it support some longer documentation for the flags, i.e. 
> "git status -h" vs "git status --help"?

Yes.  You can give an option a description, like this:

// ...
uint nr_doors;
// ...
Named("doors", nr_doors, 0) ("number of doors").AddRange(1, 4);

If you do this, the user has a nice, short name to type:

--doors 2

But the description will be used in error messages ("The number 
of doors must be between 1 and 4") and in auto-generated syntax 
summaries ("--doors <number of doors>").

For a positional parameter, the user never types the name, and so 
you just do this:

Pos("number of doors", nr_doors, 0).AddRange(1, 4);

Then the syntax element we auto-generate will be "<number of 
doors>" and error messages will be the same as for the equivalent 
named option.

Markus


More information about the Digitalmars-d-announce mailing list