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(): Help
Returns
Overrides
BaseHelp.constructor
Properties
Property | Modifier | Type | Default value |
---|---|---|---|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
| typeof |
|
Accessors
app
Get Signature
get app(): typeof Application
Returns
typeof Application
in
Get Signature
get in(): Input
Returns
out
Get Signature
get out(): Output
Returns
Methods
argumentDescription()
argumentDescription(argument): string
Returns the description for an argument.
Parameters
Parameter | Type | Description |
---|---|---|
| The argument to get the description for. |
Returns
string
The argument description.
Overrides
BaseHelp.argumentDescription
boxWrap()
boxWrap(str, width): string
Wraps 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.boxWrap
displayWidth()
displayWidth(str): number
Calculates 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.displayWidth
formatHelp()
formatHelp(cmd, helper): string
Formats 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.formatHelp
optionDescription()
optionDescription(option): string
Returns the description for an option.
Parameters
Parameter | Type | Description |
---|---|---|
| The option to get the description for. |
Returns
string
The option description.
Overrides
BaseHelp.optionDescription
optionTerm()
optionTerm(option): string
Returns 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.optionTerm
prepareContext()
prepareContext(contextOptions): void
Prepares the context for displaying help.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The context options. |
Returns
void
Overrides
BaseHelp.prepareContext
styleArgumentDescription()
styleArgumentDescription(str): string
Styles an argument description string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The argument description string to style. |
Returns
string
The styled argument description string.
Overrides
BaseHelp.styleArgumentDescription
styleArgumentText()
styleArgumentText(str): string
Styles an argument text string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The argument text string to style. |
Returns
string
The styled argument text string.
Overrides
BaseHelp.styleArgumentText
styleCommandDescription()
styleCommandDescription(str): string
Styles a command description string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The command description string to style. |
Returns
string
The styled command description string.
Overrides
BaseHelp.styleCommandDescription
styleCommandText()
styleCommandText(str): string
Styles a command text string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The command text string to style. |
Returns
string
The styled command text string.
Overrides
BaseHelp.styleCommandText
styleDescriptionText()
styleDescriptionText(str): string
Styles a description text string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The description text string to style. |
Returns
string
The styled description text string.
Overrides
BaseHelp.styleDescriptionText
styleOptionDescription()
styleOptionDescription(str): string
Styles an option description string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The option description string to style. |
Returns
string
The styled option description string.
Overrides
BaseHelp.styleOptionDescription
styleOptionText()
styleOptionText(str): string
Styles an option text string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The option text string to style. |
Returns
string
The styled option text string.
Overrides
BaseHelp.styleOptionText
styleSubcommandDescription()
styleSubcommandDescription(str): string
Styles a subcommand description string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The subcommand description string to style. |
Returns
string
The styled subcommand description string.
Overrides
BaseHelp.styleSubcommandDescription
styleSubcommandText()
styleSubcommandText(str): string
Styles a subcommand text string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The subcommand text string to style. |
Returns
string
The styled subcommand text string.
Overrides
BaseHelp.styleSubcommandText
styleTitle()
styleTitle(str): string
Styles a title string.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The title string to style. |
Returns
string
The styled title string.
Overrides
BaseHelp.styleTitle
styleUsage()
styleUsage(str): string
Styles the usage string for a command.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The usage string to style. |
Returns
string
The styled usage string.
Overrides
BaseHelp.styleUsage
visibleGlobalOptions()
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