Skip to content

Interface: CommandEnvironment<G>

Command environment.

Signature

ts
export interface CommandEnvironment<G extends GunshiParamsConstraint = DefaultGunshiParams>

Type Parameters

NameDescription
G extends GunshiParamsConstraint = DefaultGunshiParamsA type extending GunshiParams to specify the shape of command environments.

Properties

NameTypeDescription
cwdstring | undefinedCurrent working directory.
descriptionstring | undefinedCommand description.
leftMarginnumberLeft margin of the command output. Default: 2
middleMarginnumberMiddle margin of the command output. Default: 10
namestring | undefinedCommand name.
onAfterCommand((ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>) | undefinedHook that runs after successful command execution Since v0.27.0
onBeforeCommand((ctx: Readonly<CommandContext<G>>) => Awaitable<void>) | undefinedHook that runs before any command execution Since v0.27.0
onErrorCommand((ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>) | undefinedHook that runs when a command throws an error Since v0.27.0
renderHeader((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null | undefinedRender function the header section in the command usage.
renderUsage((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null | undefinedRender function the command usage.
renderValidationErrors((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null | undefinedRender function the validation errors.
subCommandsMap<string, Command<any> | LazyCommand<any>> | undefinedSub commands.
usageOptionTypebooleanWhether to display the usage option type. Default: false
usageOptionValuebooleanWhether to display the option value. Default: true
usageSilentbooleanWhether to display the command usage. Default: false
versionstring | undefinedCommand version.

Released under the MIT License.