Skip to content

Function: createCommandContext()

Create a command context.

Signature

ts
export async function createCommandContext<
  G extends GunshiParamsConstraint = DefaultGunshiParams,
  V extends ArgValues<ExtractArgs<G>> = ArgValues<ExtractArgs<G>>,
  C extends Command<G> | LazyCommand<G> = Command<G>,
  E extends Record<string, CommandContextExtension> = {}
>({
  args = {} as ExtractArgs<G>,
  explicit = {} as ExtractArgExplicitlyProvided<G>,
  values = {} as V,
  positionals = [],
  rest = [],
  argv = [],
  tokens = [],
  command = {} as C,
  extensions = {} as E,
  cliOptions = {} as CliOptions<G>,
  callMode = 'entry',
  commandPath = [],
  omitted = false,
  validationError
}: CommandContextParams<G, V, C, E>): Promise<CommandContextResult<G, E>>

Type Parameters

Name
G extends GunshiParamsConstraint = DefaultGunshiParams
V extends ArgValues<ExtractArgs<G>> = ArgValues<ExtractArgs<G>>
C extends Command<G> | LazyCommand<G> = Command<G>
E extends Record<string, CommandContextExtension> = {}

Parameters

NameTypeDescription
paramCommandContextParams<G, V, C, E>A parameters to create a command context.

Returns

Promise<CommandContextResult<G, E>> — A command context, which is readonly.

Released under the MIT License.