Members
_longNameIndex
- Source:
_longNameIndex[undefined]
- Source:
_options
- Source:
_shortNameIndex
- Source:
_shortNameIndex[undefined]
- Source:
_
- Source:
arg
- Source:
canHaveMultiple
- Source:
coercer
- Source:
currentIndex
- Source:
descriptions
- Source:
hasOwnProp
- Source:
hasValue
- Source:
helpText
- Source:
ignore
- Source:
length
- Source:
longName
- Source:
longName
- Source:
longName
- Source:
max
- Source:
names
- Source:
next
- Source:
option
- Source:
option
- Source:
partialDescription
- Source:
partialDescription
- Source:
result
- Source:
result
- Source:
result
- Source:
result
- Source:
result
- Source:
result
- Source:
shortName
- Source:
shortName
- Source:
shortName
- Source:
shortName
- Source:
value
- Source:
value
- Source:
value
- Source:
value
- Source:
words
- Source:
Methods
_addOption()
- Source:
_getOptionByLongName()
- Source:
_getOptionByShortName()
- Source:
addIgnoredOption(shortName, longName)
Provide information about an option that should not cause an error if present, but that is always
ignored (for example, an option that was used in previous versions but is no longer supported).
Parameters:
| Name | Type | Description |
|---|---|---|
shortName |
string | The short name of the option with a leading hyphen (for example, `-v`). |
longName |
string | The long name of the option with two leading hyphens (for example, `--version`). |
- Source:
addOption(shortName, longName, hasValue, helpText, canHaveMultipleopt, coerceropt) → {this}
Provide information about a legal option.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shortName |
character | The short name of the option, entered like: -T. | ||
longName |
string | The equivalent long name of the option, entered like: --test. | ||
hasValue |
boolean | Does this option require a value? Like: -t templatename | ||
helpText |
string | A brief description of the option. | ||
canHaveMultiple |
boolean |
<optional> |
false | Set to `true` if the option can be provided more than once. |
coercer |
function |
<optional> |
A function to coerce the given value to a specific type. |
- Source:
Returns:
- Type
- this
Example
myParser.addOption('t', 'template', true, 'The path to the template.');
myParser.addOption('h', 'help', false, 'Show the help message.');
help() → {string}
Generate a summary of all the options with corresponding help text.
- Source:
Returns:
- Type
- string
parse(args, defaultsopt) → {Object}
Get the options.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
args |
Array.<string> | An array, like ['-x', 'hello'] | ||
defaults |
Object |
<optional> |
{} | An optional collection of default values. |
- Source:
Returns:
The keys will be the longNames, or the shortName if no longName is defined for
that option. The values will be the values provided, or `true` if the option accepts no value.
- Type
- Object
concatWithMaxLength()
- Source:
findMaxLength()
- Source:
formatHelpInfo()
- Source:
padding()
- Source:
padLeft()
- Source:
padRight()
- Source: