Command
Defined in: packages/core/src/command.ts:112
A command.
Type Parameters
Section titled “Type Parameters”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Command<
T>(names,desc?,version?):Command<T>
Defined in: packages/core/src/command.ts:172
Creates a new command.
Parameters
Section titled “Parameters”string | string[]
The names (aliases).
string
The description.
version?
Section titled “version?”string
The version.
Returns
Section titled “Returns”Command<T>
Properties
Section titled “Properties”$allowSurpassArgLimit
Section titled “$allowSurpassArgLimit”$allowSurpassArgLimit:
boolean=false
Defined in: packages/core/src/command.ts:144
If you should be able to surpass the amount of positional arguments defined in the input.
$allowUnknownOptions
Section titled “$allowUnknownOptions”$allowUnknownOptions:
boolean=false
Defined in: packages/core/src/command.ts:140
If this command allows unknown options.
$children
Section titled “$children”$children:
Map<string,CommandAlias<Input>>
Defined in: packages/core/src/command.ts:132
The children of this command.
$description
Section titled “$description”$description:
string|undefined
Defined in: packages/core/src/command.ts:120
The description of this command.
$errorFn
Section titled “$errorFn”$errorFn:
ErrorFn<T> |undefined=undefined
Defined in: packages/core/src/command.ts:160
The error handler of this command.
$fn:
ActionFn<T> |undefined=undefined
Defined in: packages/core/src/command.ts:152
The action function of this command.
$input
Section titled “$input”$input:
T
Defined in: packages/core/src/command.ts:148
The input this command takes.
$middlewares
Section titled “$middlewares”$middlewares:
MiddlewareFn<T>[] =[]
Defined in: packages/core/src/command.ts:156
The middlewares associated with this command.
$names
Section titled “$names”$names:
string[]
Defined in: packages/core/src/command.ts:116
The names (aliases) of this command.
$parent
Section titled “$parent”$parent:
Command<any> |undefined
Defined in: packages/core/src/command.ts:136
The parent of this command.
$parser
Section titled “$parser”$parser:
Parser
Defined in: packages/core/src/command.ts:164
The argument parser to use.
$theme
Section titled “$theme”$theme:
Theme|undefined
Defined in: packages/core/src/command.ts:124
The theme of this command
$version
Section titled “$version”$version:
string|undefined
Defined in: packages/core/src/command.ts:128
The version of this command.
Methods
Section titled “Methods”action()
Section titled “action()”action(
fn):this
Defined in: packages/core/src/command.ts:234
Sets the action function for this command.
Parameters
Section titled “Parameters”ActionFn<T>
The action.
Returns
Section titled “Returns”this
this
add(…
commands):this
Defined in: packages/core/src/command.ts:254
Adds existing commands to this.
Parameters
Section titled “Parameters”commands
Section titled “commands”…Command<any>[]
The commands.
Returns
Section titled “Returns”this
this
alias()
Section titled “alias()”alias(…
aliases):this
Defined in: packages/core/src/command.ts:183
Adds a set of aliases to this command.
Parameters
Section titled “Parameters”aliases
Section titled “aliases”…string[]
The aliases to add.
Returns
Section titled “Returns”this
this
allowSurpassArgLimit()
Section titled “allowSurpassArgLimit()”allowSurpassArgLimit():
this
Defined in: packages/core/src/command.ts:445
Allows surpassing the amount of arguments specified.
Returns
Section titled “Returns”this
this
allowUnknownOptions()
Section titled “allowUnknownOptions()”allowUnknownOptions():
this
Defined in: packages/core/src/command.ts:305
Allows unknown options.
Returns
Section titled “Returns”this
this
buildInputMap()
Section titled “buildInputMap()”buildInputMap():
Map<string|number,InputMapEntry>
Defined in: packages/core/src/command.ts:418
Returns
Section titled “Returns”Map<string | number, InputMapEntry>
defaultErrorScreen()
Section titled “defaultErrorScreen()”defaultErrorScreen(
errors):void
Defined in: packages/core/src/command.ts:469
The default error screen.
Parameters
Section titled “Parameters”errors
Section titled “errors”Error[]
The errors.
Returns
Section titled “Returns”void
description()
Section titled “description()”description(
desc):this
Defined in: packages/core/src/command.ts:194
Adds a description to this command.
Parameters
Section titled “Parameters”string
The description.
Returns
Section titled “Returns”this
this
error()
Section titled “error()”error(
fn):this
Defined in: packages/core/src/command.ts:244
Sets the error function for this command.
Parameters
Section titled “Parameters”ErrorFn<T>
The error handler.
Returns
Section titled “Returns”this
this
fullCommandPath()
Section titled “fullCommandPath()”fullCommandPath():
string
Defined in: packages/core/src/command.ts:454
Gets the full command path (name including parents).
Returns
Section titled “Returns”string
The full command path.
handleErrors()
Section titled “handleErrors()”handleErrors(
errors,input?):Promise<Command<T>>
Defined in: packages/core/src/command.ts:570
Handles a set of errors.
Parameters
Section titled “Parameters”errors
Section titled “errors”Error[]
The errors to handle.
input?
Section titled “input?”Partial<InferInput<T>>
The parsed input, if possible.
Returns
Section titled “Returns”Promise<Command<T>>
this
input()
Section titled “input()”input<
TInput>(input):Command<TInput>
Defined in: packages/core/src/command.ts:214
Sets the input for this command.
Type Parameters
Section titled “Type Parameters”TInput
Section titled “TInput”TInput extends Input
Parameters
Section titled “Parameters”TInput
The input.
Returns
Section titled “Returns”Command<TInput>
this
parse()
Section titled “parse()”parse(
argv?):Promise<ValidatedParseResult<T>>
Defined in: packages/core/src/command.ts:315
Parses a set of command-line arguments.
Parameters
Section titled “Parameters”string[] = ...
The arguments to parse.
Returns
Section titled “Returns”Promise<ValidatedParseResult<T>>
A validated parse result.
run(
argv?):Promise<Command<T>>
Defined in: packages/core/src/command.ts:593
Runs a command.
Parameters
Section titled “Parameters”string[] = ...
The arguments to run the command with. Defaults to your runtime’s argv equivalent.
Returns
Section titled “Returns”Promise<Command<T>>
this
subCommand()
Section titled “subCommand()”Call Signature
Section titled “Call Signature”subCommand(
names,builder):this
Defined in: packages/core/src/command.ts:271
Creates a new subcommand and adds it.
Parameters
Section titled “Parameters”string | string[]
The aliases of the subcommand.
builder
Section titled “builder”A builder to create the command.
Returns
Section titled “Returns”this
Call Signature
Section titled “Call Signature”subCommand(
names,desc?,version?):Command<any>
Defined in: packages/core/src/command.ts:278
Creates a new subcommand and adds it.
Parameters
Section titled “Parameters”string | string[]
The aliases of the subcommand.
string
The description of the subcommand.
version?
Section titled “version?”string
The version of the subcommand.
Returns
Section titled “Returns”Command<any>
use(…
fns):this
Defined in: packages/core/src/command.ts:224
Adds a chain of middlewares.
Parameters
Section titled “Parameters”…MiddlewareFn<T>[]
The middlewares to use.
Returns
Section titled “Returns”this
this
version()
Section titled “version()”version(
version):this
Defined in: packages/core/src/command.ts:204
Adds a version to this command.
Parameters
Section titled “Parameters”version
Section titled “version”string
The version.
Returns
Section titled “Returns”this
this