Interface: CliOptions<G>
CLI options of cli function.
Signature
ts
export interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams>Type Parameters
| Name | Description |
|---|---|
G extends GunshiParamsConstraint = DefaultGunshiParams | A type extending GunshiParams to specify the shape of cli options. |
Properties
| Name | Type | Description |
|---|---|---|
cwd (optional) | string | Current working directory. |
description (optional) | string | Command program description. |
fallbackToEntry (optional) | boolean | Whether to fallback to entry command when the sub-command is not found. Default: false Since v0.27.0 |
leftMargin (optional) | number | Left margin of the command output. |
middleMargin (optional) | number | Middle margin of the command output. |
name (optional) | string | Command 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>) | null | Render function the header section in the command usage. |
renderUsage (optional) | ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null | Render function the command usage. |
renderValidationErrors (optional) | ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null | Render function the validation errors. |
subCommands (optional) | Record<string, SubCommandable> | Map<string, SubCommandable> | Sub commands. |
usageOptionType (optional) | boolean | Whether to display the usage optional argument type. |
usageOptionValue (optional) | boolean | Whether to display the optional argument value. |
usageSilent (optional) | boolean | Whether to display the command usage. |
version (optional) | string | Command program version. |
onAfterCommand Parameters
| Name | Type | Description |
|---|---|---|
ctx | Readonly<CommandContext<G>> | The command context |
result | string | undefined | The command execution result |
onAfterCommand Returns
Awaitable<void>
onBeforeCommand Parameters
| Name | Type | Description |
|---|---|---|
ctx | Readonly<CommandContext<G>> | The command context |
onBeforeCommand Returns
Awaitable<void>
onErrorCommand Parameters
| Name | Type | Description |
|---|---|---|
ctx | Readonly<CommandContext<G>> | The command context |
error | Error | The error thrown during execution |
onErrorCommand Returns
Awaitable<void>
