Skip to content

Command

Defined in: packages/core/dist/index.d.mts:212

A command.

T extends Input = Input

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

Defined in: packages/core/dist/index.d.mts:271

Creates a new command.

string | string[]

The names (aliases).

string

The description.

string

The version.

Command<T>

$allowSurpassArgLimit: boolean

Defined in: packages/core/dist/index.d.mts:244

If you should be able to surpass the amount of positional arguments defined in the input.


$allowUnknownOptions: boolean

Defined in: packages/core/dist/index.d.mts:240

If this command allows unknown options.


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

Defined in: packages/core/dist/index.d.mts:232

The children of this command.


$description: string | undefined

Defined in: packages/core/dist/index.d.mts:220

The description of this command.


$errorFn: ErrorFn<T> | undefined

Defined in: packages/core/dist/index.d.mts:260

The error handler of this command.


$fn: ActionFn<T> | undefined

Defined in: packages/core/dist/index.d.mts:252

The action function of this command.


$input: T

Defined in: packages/core/dist/index.d.mts:248

The input this command takes.


$middlewares: MiddlewareFn<T>[]

Defined in: packages/core/dist/index.d.mts:256

The middlewares associated with this command.


$names: string[]

Defined in: packages/core/dist/index.d.mts:216

The names (aliases) of this command.


$parent: Command<any> | undefined

Defined in: packages/core/dist/index.d.mts:236

The parent of this command.


$parser: Parser

Defined in: packages/core/dist/index.d.mts:264

The argument parser to use.


$theme: Theme | undefined

Defined in: packages/core/dist/index.d.mts:224

The theme of this command


$version: string | undefined

Defined in: packages/core/dist/index.d.mts:228

The version of this command.

action(fn): this

Defined in: packages/core/dist/index.d.mts:307

Sets the action function for this command.

ActionFn<T>

The action.

this

this


add(…commands): this

Defined in: packages/core/dist/index.d.mts:319

Adds existing commands to this.

Command<any>[]

The commands.

this

this


alias(…aliases): this

Defined in: packages/core/dist/index.d.mts:277

Adds a set of aliases to this command.

string[]

The aliases to add.

this

this


allowSurpassArgLimit(): this

Defined in: packages/core/dist/index.d.mts:349

Allows surpassing the amount of arguments specified.

this

this


allowUnknownOptions(): this

Defined in: packages/core/dist/index.d.mts:337

Allows unknown options.

this

this


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

Defined in: packages/core/dist/index.d.mts:344

Map<string | number, InputMapEntry>


defaultErrorScreen(errors): void

Defined in: packages/core/dist/index.d.mts:359

The default error screen.

Error[]

The errors.

void


description(desc): this

Defined in: packages/core/dist/index.d.mts:283

Adds a description to this command.

string

The description.

this

this


error(fn): this

Defined in: packages/core/dist/index.d.mts:313

Sets the error function for this command.

ErrorFn<T>

The error handler.

this

this


fullCommandPath(): string

Defined in: packages/core/dist/index.d.mts:354

Gets the full command path (name including parents).

string

The full command path.


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

Defined in: packages/core/dist/index.d.mts:366

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/dist/index.d.mts:295

Sets the input for this command.

TInput extends Input

TInput

The input.

Command<TInput>

this


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

Defined in: packages/core/dist/index.d.mts:343

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/dist/index.d.mts:372

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/dist/index.d.mts:325

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/dist/index.d.mts:332

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/dist/index.d.mts:301

Adds a chain of middlewares.

MiddlewareFn<T>[]

The middlewares to use.

this

this


version(version): this

Defined in: packages/core/dist/index.d.mts:289

Adds a version to this command.

string

The version.

this

this