Fork me on GitHub

Module ringo/args

A parser for command line options.

Class Parser

Instance Methods


Parser ()

Create a new command line option parser.


Parser.prototype.addOption (shortName, longName, argument, helpText)

Add an option to the parser.

Parameters

shortName the short option name (without leading hyphen)
longName the long option name (without leading hyphens)
argument the name of the argument if the option requires one, or null
helpText the help text to display for the option

Parser.prototype.help ()

Get help text for the parser's options suitable for display in command line scripts.


Parser.prototype.parse (args, result)

Parse an arguments array into an option object.

Parameters

args the argument array. Matching options are removed.
result optional result object. If undefined, a new Object is created

Returns

the result object