GlobalOptionsCommand
Constructors
new GlobalOptionsCommand()
new GlobalOptionsCommand(): GlobalOptionsCommandReturns
Overrides
Properties
| Property | Modifier | Type | Inherited from |
|---|---|---|---|
|
Methods
add()
add<T, Usage>(
flags,
description,
defaultValue): OptionType Parameters
| Type Parameter | Default type |
|---|---|
| ‐ |
|
|
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
addOption()
addOption(option): thisAdd a prepared Option.
See .option() and .requiredOption() for creating and attaching an option in a single call.
Parameters
| Parameter | Type |
|---|---|
|
Returns
this
Overrides
BaseCommand.addOptionautocomplete()
autocomplete(argv): thisParameters
| Parameter | Type |
|---|---|
|
|
Returns
this
Overrides
autocompleteCandidates()
autocompleteCandidates(typedArgs): any[]Parameters
| Parameter | Type |
|---|---|
|
|
Returns
any[]
Inherited from
BaseCommand.autocompleteCandidates
autocompleteHandleEvent()
autocompleteHandleEvent(event): voidParameters
| Parameter | Type |
|---|---|
|
|
Returns
void
Inherited from
BaseCommand.autocompleteHandleEvent
autocompleteNormalizeRules()
autocompleteNormalizeRules(): NormalizedCompletionRulesReturns
Inherited from
BaseCommand.autocompleteNormalizeRules
clearOptions()
clearOptions(): thisReturns
this
complete()
complete(rules): GlobalOptionsCommandParameters
| Parameter | Type |
|---|---|
|
|
Returns
Inherited from
createOption()
createOption(
flags,
description,
defaultValue?): OptionFactory routine to create a new unattached option.
See .option() for creating an attached option, which uses this routine to create the option. You can override createOption to return a custom option.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Overrides
BaseCommand.createOptiongetAutocompleteSubCommand()
getAutocompleteSubCommand(
event,
elements,
commandName,
commandArgs): GlobalOptionsCommandParameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
Returns
Inherited from
BaseCommand.getAutocompleteSubCommand
hasCompletionRules()
hasCompletionRules(): booleanReturns
boolean
Inherited from
BaseCommand.hasCompletionRules
parse()
parse(argv?, parseOptions?): thisParse argv, setting options and invoking commands when defined.
Use parseAsync instead of parse if any of your action handlers are async.
Call with no parameters to parse process.argv. Detects Electron and special node options like node --eval. Easy mode!
Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are from:
'node': default,argv[0]is the application andargv[1]is the script being run, with user arguments after that'electron':argv[0]is the application andargv[1]varies depending on whether the electron application is packaged'user': just user arguments
Parameters
| Parameter | Type |
|---|---|
| readonly |
|
|
Returns
this
this command for chaining
Example
program.parse(); // parse process.argv and auto-detect electron and special node flags
program.parse(process.argv); // assume argv[0] is app and argv[1] is script
program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]Inherited from
parseAsync()
parseAsync(argv?, parseOptions?): Promise<GlobalOptionsCommand>Parse argv, setting options and invoking commands when defined.
Call with no parameters to parse process.argv. Detects Electron and special node options like node --eval. Easy mode!
Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are from:
'node': default,argv[0]is the application andargv[1]is the script being run, with user arguments after that'electron':argv[0]is the application andargv[1]varies depending on whether the electron application is packaged'user': just user arguments
Parameters
| Parameter | Type |
|---|---|
| readonly |
|
|
Returns
Promise<GlobalOptionsCommand>
Promise
Example
await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]Inherited from
removeOption()
removeOption(option): thisParameters
| Parameter | Type |
|---|---|
|
|
Returns
this