GlobalOptionsCommand
Constructors
new GlobalOptionsCommand()
new GlobalOptionsCommand(): GlobalOptionsCommand
Returns
Overrides
Properties
Property | Modifier | Type | Inherited from |
---|---|---|---|
|
Methods
add()
add<T, Usage>(
flags,
description,
defaultValue): Option
Type Parameters
Type Parameter | Default type |
---|---|
| ‐ |
|
|
Parameters
Parameter | Type |
---|---|
|
|
|
|
|
|
Returns
addOption()
addOption(option): this
Add a prepared Option.
See .option() and .requiredOption() for creating and attaching an option in a single call.
Parameters
Parameter | Type |
---|---|
|
Returns
this
Overrides
BaseCommand.addOption
autocomplete()
autocomplete(argv): this
Parameters
Parameter | Type |
---|---|
|
|
Returns
this
Overrides
autocompleteCandidates()
autocompleteCandidates(typedArgs): any[]
Parameters
Parameter | Type |
---|---|
|
|
Returns
any
[]
Inherited from
BaseCommand
.autocompleteCandidates
autocompleteHandleEvent()
autocompleteHandleEvent(event): void
Parameters
Parameter | Type |
---|---|
|
|
Returns
void
Inherited from
BaseCommand
.autocompleteHandleEvent
autocompleteNormalizeRules()
autocompleteNormalizeRules(): NormalizedCompletionRules
Returns
Inherited from
BaseCommand
.autocompleteNormalizeRules
clearOptions()
clearOptions(): this
Returns
this
complete()
complete(rules): GlobalOptionsCommand
Parameters
Parameter | Type |
---|---|
|
|
Returns
Inherited from
createOption()
createOption(
flags,
description,
defaultValue?): Option
Factory 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.createOption
getAutocompleteSubCommand()
getAutocompleteSubCommand(
event,
elements,
commandName,
commandArgs): GlobalOptionsCommand
Parameters
Parameter | Type |
---|---|
|
|
|
|
|
|
|
|
Returns
Inherited from
BaseCommand
.getAutocompleteSubCommand
hasCompletionRules()
hasCompletionRules(): boolean
Returns
boolean
Inherited from
BaseCommand
.hasCompletionRules
parse()
parse(argv?, parseOptions?): this
Parse 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): this
Parameters
Parameter | Type |
---|---|
|
|
Returns
this