Function: cli()
Run the command.
Type Param
A type extending GunshiParams to specify the shape of command and cli options.
Param
Command line arguments
Param
A entry command, an inline command runner, or a lazily-loaded command
Param
Call Signature
function cli<G>(
args,
entry,
options?): Promise<string | undefined>;Run the command.
Type Parameters
| Type Parameter | Description |
|---|---|
G extends GunshiParamsConstraint | A type extending GunshiParams to specify the shape of command and cli options. |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string[] | Command line arguments |
entry | | Command<G> | CommandRunner<G> | LazyCommand<G> | A entry command, an inline command runner, or a lazily-loaded command |
options? | CliOptions<G> | A CLI options |
Returns
Promise<string | undefined>
A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.
Call Signature
function cli<A, G>(
args,
entry,
options?): Promise<string | undefined>;Run the command.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
A extends Args | Args | The type of arguments defined in the command and cli options. |
G extends GunshiParams<{ args: Args; extensions: { }; }> | object | - |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string[] | Command line arguments |
entry | | Command<G> | CommandRunner<G> | LazyCommand<G> | A entry command, an inline command runner, or a lazily-loaded command |
options? | CliOptions<G> | A CLI options |
Returns
Promise<string | undefined>
A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.
Call Signature
function cli<E, G>(
args,
entry,
options?): Promise<string | undefined>;Run the command.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
E extends ExtendContext | ExtendContext | An ExtendContext type to specify the shape of command and cli options. |
G extends GunshiParams<{ args: Args; extensions: { }; }> | object | - |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string[] | Command line arguments |
entry | | Command<G> | CommandRunner<G> | LazyCommand<G> | A entry command, an inline command runner, or a lazily-loaded command |
options? | CliOptions<G> | A CLI options |
Returns
Promise<string | undefined>
A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.
Call Signature
function cli<G>(
args,
entry,
options?): Promise<string | undefined>;Run the command.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
G extends GunshiParams<{ args: Args; extensions: { }; }> | DefaultGunshiParams | A type extending GunshiParams to specify the shape of command and cli options. |
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string[] | Command line arguments |
entry | | Command<G> | CommandRunner<G> | LazyCommand<G> | A entry command, an inline command runner, or a lazily-loaded command |
options? | CliOptions<G> | A CLI options |
Returns
Promise<string | undefined>
A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.
Call Signature
function cli(
args,
entry,
options?): Promise<string | undefined>;Run the command.
This overload accepts any command-like object using a loose structural type. It bypasses TypeScript contravariance issues with callback properties.
Note: This overload MUST be last in the overload list. TypeScript checks overloads in declaration order and selects the first matching one. The SubCommandable type is intentionally loose and would match any command, so placing it first would prevent proper type inference for more specific command types.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string[] | Command line arguments |
entry | SubCommandable | A command-like object (command, command runner, or lazy command) |
options? | CliOptions<DefaultGunshiParams> | A CLI options |
Returns
Promise<string | undefined>
A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.
