gunshi / default / CommandContext
Interface: CommandContext<G>
Command context. Command context is the context of the command execution.
Type Parameters
Type Parameter | Default type |
---|---|
G extends GunshiParamsConstraint | DefaultGunshiParams |
Properties
Property | Type | Description |
---|---|---|
_ | string [] | Original command line arguments. This argument is passed from cli function. |
args | ExtractArgs <G > | Command arguments, that is the arguments of the command that is executed. The command arguments is same Command.args. |
callMode | CommandCallMode | Command call mode. The command call mode is entry when the command is executed as an entry command, and subCommand when the command is executed as a sub-command. |
description | undefined | string | Command description, that is the description of the command that is executed. The command description is same CommandEnvironment.description. |
env | Readonly <CommandEnvironment <G >> | Command environment, that is the environment of the command that is executed. The command environment is same CommandEnvironment. |
explicit | ExtractArgExplicitlyProvided <G > | Whether arguments were explicitly provided by the user. - true : The argument was explicitly provided via command line - false : The argument was not explicitly provided. This means either: - The value comes from a default value defined in the argument schema - The value is undefined (no explicit input and no default value) |
extensions | keyof ExtractExtensions <G > extends never ? undefined : ExtractExtensions <G > | Command context extensions. Since v0.27.0 |
log | (message? , ...optionalParams ) => void | Output a message. If CommandEnvironment.usageSilent is true, the message is not output. See - console.log - console.log |
name | undefined | string | Command name, that is the command that is executed. The command name is same CommandEnvironment.name. |
omitted | boolean | Whether the currently executing command has been executed with the sub-command name omitted. |
positionals | string [] | Command positionals arguments, that is the positionals of the command that is executed. Resolve positionals with resolveArgs from command arguments. |
rest | string [] | Command rest arguments, that is the remaining argument not resolved by the optional command option delimiter -- . |
toKebab? | boolean | Whether to convert the camel-case style argument name to kebab-case. This context value is set from Command.toKebab option. |
tokens | ArgToken [] | Argument tokens, that is parsed by parseArgs function. |
validationError? | AggregateError | Validation error from argument parsing. This will be set if argument validation fails during CLI execution. |
values | ArgValues <ExtractArgs <G >> | Command values, that is the values of the command that is executed. Resolve values with resolveArgs from command arguments and Command.args. |