Skip to content

Command

Defined in: packages/core/src/command.ts:112

A command.

T extends Input = Input

new Command<T>(names, desc?, version?): Command<T>

Defined in: packages/core/src/command.ts:172

Creates a new command.

string | string[]

The names (aliases).

string

The description.

string

The version.

Command<T>

$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: boolean = false

Defined in: packages/core/src/command.ts:140

If this command allows unknown options.


$children: Map<string, CommandAlias<Input>>

Defined in: packages/core/src/command.ts:132

The children of this command.


$description: string | undefined

Defined in: packages/core/src/command.ts:120

The description of this command.


$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: T

Defined in: packages/core/src/command.ts:148

The input this command takes.


$middlewares: MiddlewareFn<T>[] = []

Defined in: packages/core/src/command.ts:156

The middlewares associated with this command.


$names: string[]

Defined in: packages/core/src/command.ts:116

The names (aliases) of this command.


$parent: Command<any> | undefined

Defined in: packages/core/src/command.ts:136

The parent of this command.


$parser: Parser

Defined in: packages/core/src/command.ts:164

The argument parser to use.


$theme: Theme | undefined

Defined in: packages/core/src/command.ts:124

The theme of this command


$version: string | undefined

Defined in: packages/core/src/command.ts:128

The version of this command.

action(fn): this

Defined in: packages/core/src/command.ts:234

Sets the action function for this command.

ActionFn<T>

The action.

this

this


add(…commands): this

Defined in: packages/core/src/command.ts:254

Adds existing commands to this.

Command<any>[]

The commands.

this

this


alias(…aliases): this

Defined in: packages/core/src/command.ts:183

Adds a set of aliases to this command.

string[]

The aliases to add.

this

this


allowSurpassArgLimit(): this

Defined in: packages/core/src/command.ts:445

Allows surpassing the amount of arguments specified.

this

this


allowUnknownOptions(): this

Defined in: packages/core/src/command.ts:305

Allows unknown options.

this

this


buildInputMap(): Map<string | number, InputMapEntry>

Defined in: packages/core/src/command.ts:418

Map<string | number, InputMapEntry>


defaultErrorScreen(errors): void

Defined in: packages/core/src/command.ts:469

The default error screen.

Error[]

The errors.

void


description(desc): this

Defined in: packages/core/src/command.ts:194

Adds a description to this command.

string

The description.

this

this


error(fn): this

Defined in: packages/core/src/command.ts:244

Sets the error function for this command.

ErrorFn<T>

The error handler.

this

this


fullCommandPath(): string

Defined in: packages/core/src/command.ts:454

Gets the full command path (name including parents).

string

The full command path.


handleErrors(errors, input?): Promise<Command<T>>

Defined in: packages/core/src/command.ts:570

Handles a set of errors.

Error[]

The errors to handle.

Partial<InferInput<T>>

The parsed input, if possible.

Promise<Command<T>>

this


input<TInput>(input): Command<TInput>

Defined in: packages/core/src/command.ts:214

Sets the input for this command.

TInput extends Input

TInput

The input.

Command<TInput>

this


parse(argv?): Promise<ValidatedParseResult<T>>

Defined in: packages/core/src/command.ts:315

Parses a set of command-line arguments.

string[] = ...

The arguments to parse.

Promise<ValidatedParseResult<T>>

A validated parse result.


run(argv?): Promise<Command<T>>

Defined in: packages/core/src/command.ts:593

Runs a command.

string[] = ...

The arguments to run the command with. Defaults to your runtime’s argv equivalent.

Promise<Command<T>>

this


subCommand(names, builder): this

Defined in: packages/core/src/command.ts:271

Creates a new subcommand and adds it.

string | string[]

The aliases of the subcommand.

Builder

A builder to create the command.

this

subCommand(names, desc?, version?): Command<any>

Defined in: packages/core/src/command.ts:278

Creates a new subcommand and adds it.

string | string[]

The aliases of the subcommand.

string

The description of the subcommand.

string

The version of the subcommand.

Command<any>


use(…fns): this

Defined in: packages/core/src/command.ts:224

Adds a chain of middlewares.

MiddlewareFn<T>[]

The middlewares to use.

this

this


version(version): this

Defined in: packages/core/src/command.ts:204

Adds a version to this command.

string

The version.

this

this