BaseCommand
Constructors
new BaseCommand()
new BaseCommand(name?): BaseCommand
Parameters
Parameter | Type |
---|---|
|
|
Returns
Inherited from
_Command.constructor
Properties
Property | Modifier | Type |
---|---|---|
|
Methods
autocomplete()
autocomplete(argv): BaseCommand
Parameters
Parameter | Type |
---|---|
|
|
Returns
autocompleteCandidates()
autocompleteCandidates(typedArgs): any[]
Parameters
Parameter | Type |
---|---|
|
|
Returns
any
[]
autocompleteHandleEvent()
autocompleteHandleEvent(event): void
Parameters
Parameter | Type |
---|---|
|
|
Returns
void
autocompleteNormalizeRules()
autocompleteNormalizeRules(): NormalizedCompletionRules
Returns
complete()
complete(rules): BaseCommand
Parameters
Parameter | Type |
---|---|
|
|
Returns
getAutocompleteSubCommand()
getAutocompleteSubCommand(
event,
elements,
commandName,
commandArgs): BaseCommand
Parameters
Parameter | Type |
---|---|
|
|
|
|
|
|
|
|
Returns
hasCompletionRules()
hasCompletionRules(): boolean
Returns
boolean
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]
Overrides
_Command.parse
parseAsync()
parseAsync(argv?, parseOptions?): Promise<BaseCommand>
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
<BaseCommand
>
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]
Overrides
_Command.parseAsync