Help
The Help class extends the base help functionality provided by commander. It customizes the display of command-line help, including options, arguments, and commands. This class supports additional formatting and styling options for better readability.
Example
const help = new Help();
help.seperateOptionsByNewLine = true;
help.useExtraInfoColumn = true;
const output = help.formatHelp(command, help);
console.log(output);Constructors
new Help()
new Help(): HelpReturns
Overrides
BaseHelp.constructorProperties
| Property | Modifier | Type | Default value |
|---|---|---|---|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
| typeof |
|
Accessors
app
Get Signature
get app(): typeof ApplicationReturns
typeof Application
in
Get Signature
get in(): InputReturns
out
Get Signature
get out(): OutputReturns
Methods
argumentDescription()
argumentDescription(argument): stringReturns the description for an argument.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The argument to get the description for. |
Returns
string
The argument description.
Overrides
BaseHelp.argumentDescriptionboxWrap()
boxWrap(str, width): stringWraps a string to a specified width, preserving words.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The string to wrap. |
|
| The maximum width of the wrapped string. |
Returns
string
The wrapped string.
Overrides
BaseHelp.boxWrapdisplayWidth()
displayWidth(str): numberCalculates the display width of a string, excluding ANSI escape codes.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The string to measure. |
Returns
number
The display width of the string.
Overrides
BaseHelp.displayWidthformatHelp()
formatHelp(cmd, helper): stringFormats the help for a command.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The command to format the help for. | |
|
| The help instance. |
Returns
string
The formatted help string.
Overrides
BaseHelp.formatHelpoptionDescription()
optionDescription(option): stringReturns the description for an option.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The option to get the description for. |
Returns
string
The option description.
Overrides
BaseHelp.optionDescriptionoptionTerm()
optionTerm(option): stringReturns the term for an option, with additional styling.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The option to get the term for. |
Returns
string
The styled option term.
Overrides
BaseHelp.optionTermprepareContext()
prepareContext(contextOptions): voidPrepares the context for displaying help.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The context options. |
Returns
void
Overrides
BaseHelp.prepareContextstyleArgumentDescription()
styleArgumentDescription(str): stringStyles an argument description string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The argument description string to style. |
Returns
string
The styled argument description string.
Overrides
BaseHelp.styleArgumentDescriptionstyleArgumentText()
styleArgumentText(str): stringStyles an argument text string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The argument text string to style. |
Returns
string
The styled argument text string.
Overrides
BaseHelp.styleArgumentTextstyleCommandDescription()
styleCommandDescription(str): stringStyles a command description string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The command description string to style. |
Returns
string
The styled command description string.
Overrides
BaseHelp.styleCommandDescriptionstyleCommandText()
styleCommandText(str): stringStyles a command text string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The command text string to style. |
Returns
string
The styled command text string.
Overrides
BaseHelp.styleCommandTextstyleDescriptionText()
styleDescriptionText(str): stringStyles a description text string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The description text string to style. |
Returns
string
The styled description text string.
Overrides
BaseHelp.styleDescriptionTextstyleOptionDescription()
styleOptionDescription(str): stringStyles an option description string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The option description string to style. |
Returns
string
The styled option description string.
Overrides
BaseHelp.styleOptionDescriptionstyleOptionText()
styleOptionText(str): stringStyles an option text string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The option text string to style. |
Returns
string
The styled option text string.
Overrides
BaseHelp.styleOptionTextstyleSubcommandDescription()
styleSubcommandDescription(str): stringStyles a subcommand description string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The subcommand description string to style. |
Returns
string
The styled subcommand description string.
Overrides
BaseHelp.styleSubcommandDescriptionstyleSubcommandText()
styleSubcommandText(str): stringStyles a subcommand text string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The subcommand text string to style. |
Returns
string
The styled subcommand text string.
Overrides
BaseHelp.styleSubcommandTextstyleTitle()
styleTitle(str): stringStyles a title string.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The title string to style. |
Returns
string
The styled title string.
Overrides
BaseHelp.styleTitlestyleUsage()
styleUsage(str): stringStyles the usage string for a command.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The usage string to style. |
Returns
string
The styled usage string.
Overrides
BaseHelp.styleUsagevisibleGlobalOptions()
visibleGlobalOptions(_cmd): Option[]Returns the visible global options for a command.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The command to get the global options for. |
Returns
Option[]
The visible global options.
Overrides
BaseHelp.visibleGlobalOptions