Skip to content

gunshi / default / CommandEnvironment

Interface: CommandEnvironment<G>

Command environment.

Type Parameters

Type ParameterDefault typeDescription
G extends GunshiParamsConstraintDefaultGunshiParamsA type extending GunshiParams to specify the shape of command environments.

Properties

PropertyTypeDescription
cwdstring | undefinedCurrent working directory. See CliOptions.cwd
descriptionstring | undefinedCommand description. See CliOptions.description
leftMarginnumberLeft margin of the command output. Default 2 See CliOptions.leftMargin
middleMarginnumberMiddle margin of the command output. Default 10 See CliOptions.middleMargin
namestring | undefinedCommand name. See CliOptions.name
onAfterCommand| (ctx, result) => Awaitable<void> | undefinedHook that runs after successful command execution See CliOptions.onAfterCommand Since v0.27.0
onBeforeCommand| (ctx) => Awaitable<void> | undefinedHook that runs before any command execution See CliOptions.onBeforeCommand Since v0.27.0
onErrorCommand| (ctx, error) => Awaitable<void> | undefinedHook that runs when a command throws an error See CliOptions.onErrorCommand Since v0.27.0
renderHeader(ctx) => Promise<string> | null | undefinedRender function the header section in the command usage.
renderUsage(ctx) => Promise<string> | null | undefinedRender function the command usage.
renderValidationErrors(ctx, error) => Promise<string> | null | undefinedRender function the validation errors.
subCommands| Map<string, | Command<any> | LazyCommand<any, { }>> | undefinedSub commands. See CliOptions.subCommands
usageOptionTypebooleanWhether to display the usage option type. Default false See CliOptions.usageOptionType
usageOptionValuebooleanWhether to display the option value. Default true See CliOptions.usageOptionValue
usageSilentbooleanWhether to display the command usage. Default false See CliOptions.usageSilent
versionstring | undefinedCommand version. See CliOptions.version

Released under the MIT License.