Skip to content

Type Alias: CommandLoader<G> ​

Command loader.

A function that returns a command or command runner. This is used to lazily load commands.

Any other value, such as null or undefined, fails with Cannot resolve command: <name>. To tell what went wrong, such as a module that is not found, throw an error instead, such as a CommandError. An error of the loading is thrown where the command would run, as an error of run is: a CommandError prints its message with its exit code, --json prints the failure as JSON, and onErrorCommand sees it. Until then, the definition given to lazy stands for the command, so that --help prints its usage.

Signature ​

ts
export type CommandLoader<G extends GunshiParamsConstraint = DefaultGunshiParams> = () => Awaitable<Command<G> | CommandRunner<G>>

Type Parameters ​

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

Returns ​

Awaitable<Command<G> | CommandRunner<G>> — A command or command runner

Released under the MIT License.