Skip to content

Interface: CliOptions<G> ​

CLI options of cli function.

Signature ​

ts
export interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams>

Type Parameters ​

NameDescription
G extends GunshiParamsConstraint = DefaultGunshiParamsA type extending GunshiParams to specify the shape of cli options.

Properties ​

NameTypeDescription
cwd (optional)stringCurrent working directory.
description (optional)stringCommand program description.
fallbackToEntry (optional)booleanWhether to fallback to entry command when the sub-command is not found. Default: false Since v0.27.0
leftMargin (optional)numberLeft margin of the command output.
middleMargin (optional)numberMiddle margin of the command output.
name (optional)stringCommand program name.
onAfterCommand (optional)(ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>Hook that runs after successful command execution Since v0.27.0
onBeforeCommand (optional)(ctx: Readonly<CommandContext<G>>) => Awaitable<void>Hook that runs before any command execution Since v0.27.0
onErrorCommand (optional)(ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>Hook that runs when a command throws an error Since v0.27.0
plugins (optional)Plugin[]User plugins. Since v0.27.0
renderHeader (optional)((ctx: Readonly<CommandContext<G>>) => Promise<string>) | nullRender function the header section in the command usage.
renderUsage (optional)((ctx: Readonly<CommandContext<G>>) => Promise<string>) | nullRender function the command usage.
renderValidationErrors (optional)((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | nullRender function the validation errors.
subCommands (optional)Record<string, SubCommandable> | Map<string, SubCommandable>Sub commands.
usageOptionType (optional)booleanWhether to display the usage optional argument type.
usageOptionValue (optional)booleanWhether to display the optional argument value.
usageSilent (optional)booleanWhether to display the command usage.
version (optional)stringCommand program version.

onAfterCommand Parameters ​

NameTypeDescription
ctxReadonly<CommandContext<G>>The command context
resultstring | undefinedThe command execution result

onAfterCommand Returns ​

Awaitable<void>

onBeforeCommand Parameters ​

NameTypeDescription
ctxReadonly<CommandContext<G>>The command context

onBeforeCommand Returns ​

Awaitable<void>

onErrorCommand Parameters ​

NameTypeDescription
ctxReadonly<CommandContext<G>>The command context
errorErrorThe error thrown during execution

onErrorCommand Returns ​

Awaitable<void>

Released under the MIT License.