Interface: CommandEnvironment<G>
Command environment.
Signature
ts
export interface CommandEnvironment<G extends GunshiParamsConstraint = DefaultGunshiParams>Type Parameters
| Name | Description |
|---|---|
G extends GunshiParamsConstraint = DefaultGunshiParams | A type extending GunshiParams to specify the shape of command environments. |
Properties
| Name | Type | Description |
|---|---|---|
cwd | string | undefined | Current working directory. |
description | string | undefined | Command description. |
leftMargin | number | Left margin of the command output. Default: 2 |
middleMargin | number | Middle margin of the command output. Default: 10 |
name | string | undefined | Command name. |
onAfterCommand | ((ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>) | undefined | Hook that runs after successful command execution Since v0.27.0 |
onBeforeCommand | ((ctx: Readonly<CommandContext<G>>) => Awaitable<void>) | undefined | Hook that runs before any command execution Since v0.27.0 |
onErrorCommand | ((ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>) | undefined | Hook that runs when a command throws an error Since v0.27.0 |
renderHeader | ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null | undefined | Render function the header section in the command usage. |
renderUsage | ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null | undefined | Render function the command usage. |
renderValidationErrors | ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null | undefined | Render function the validation errors. |
subCommands | Map<string, Command<any> | LazyCommand<any>> | undefined | Sub commands. |
usageOptionType | boolean | Whether to display the usage option type. Default: false |
usageOptionValue | boolean | Whether to display the option value. Default: true |
usageSilent | boolean | Whether to display the command usage. Default: false |
version | string | undefined | Command version. |
