Skip to content

gunshi / default / cli

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

A CLI options

Call Signature

ts
function cli<G>(
   args, 
   entry, 
options?): Promise<undefined | string>;

Run the command.

Type Parameters

Type ParameterDescription
G extends GunshiParamsConstraintA type extending GunshiParams to specify the shape of command and cli options.

Parameters

ParameterTypeDescription
argsstring[]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<undefined | string>

A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.

Call Signature

ts
function cli<A, G>(
   args, 
   entry, 
options?): Promise<undefined | string>;

Run the command.

Type Parameters

Type ParameterDefault typeDescription
A extends ArgsArgsThe type of arguments defined in the command and cli options.
G extends GunshiParams<{ args: Args; extensions: { }; }>object-

Parameters

ParameterTypeDescription
argsstring[]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<undefined | string>

A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.

Call Signature

ts
function cli<E, G>(
   args, 
   entry, 
options?): Promise<undefined | string>;

Run the command.

Type Parameters

Type ParameterDefault typeDescription
E extends ExtendContextExtendContextAn ExtendContext type to specify the shape of command and cli options.
G extends GunshiParams<{ args: Args; extensions: { }; }>object-

Parameters

ParameterTypeDescription
argsstring[]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<undefined | string>

A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.

Call Signature

ts
function cli<G>(
   args, 
   entry, 
options?): Promise<undefined | string>;

Run the command.

Type Parameters

Type ParameterDefault typeDescription
G extends GunshiParams<{ args: Args; extensions: { }; }>DefaultGunshiParamsA type extending GunshiParams to specify the shape of command and cli options.

Parameters

ParameterTypeDescription
argsstring[]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<undefined | string>

A rendered usage or undefined. if you will use CliOptions.usageSilent option, it will return rendered usage string.

Released under the MIT License.