Type Alias: CommandDecorator<G>
Command decorator.
A function that wraps a command runner to add or modify its behavior.
The decorated runner returns what the base runner returns, as it is: the result of a command that spreads jsonArgs must reach the global options plugin, which prints it as JSON with --json. A decorator prints with ctx.log, which is silenced then.
Since
v0.27.0
Signature
ts
export type CommandDecorator<G extends GunshiParamsConstraint = DefaultGunshiParams> = (baseRunner: (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void | JsonResult>) => (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void | JsonResult>Type Parameters
| Name | Description |
|---|---|
G extends GunshiParamsConstraint = DefaultGunshiParams | A type extending GunshiParams to specify the shape of command context. |
Parameters
| Name | Type | Description |
|---|---|---|
baseRunner | (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void | JsonResult> | The base command runner to decorate |
Returns
(ctx: Readonly<CommandContext<G>>) => Awaitable<string | void | JsonResult> — The decorated command runner
