The parsed option values for the command.
A list of the resolved commands.
The result of the most recent execution.
Readonly
addAppend additional options to the context's options config. Typically, this is done by plugins during initialization.
The options config to be merged with the context's options config.
Readonly
executeExecute the context's command string.
This function will override the context's result with the result of the final command in the chain each time it is called.
Optional
initialData: anyOptional data to be passed to the first command in the chain.
Readonly
exitReadonly
parseParse a command string into a structured object using the configured
parseFn
and the context's options config.
This function has no side effects and is simply a wrapper around the
configured parseFn
.
The command string to be parsed. Defaults to the context's command string.
Optional
optionsConfig: OptionsConfigAdditional options config to be merged with the context's options config.
A ParsedCommand
object containing the parsed command tokens and
option values.
Readonly
resolveResolve a command string into a list of imported command modules using
the configured resolveFn
and parseFn
.
This function has no side effects and is simply a wrapper around the
configured resolveFn
and parseFn
.
The command string to be resolved. Defaults to the context's command string.
The path to the directory containing command modules. Defaults to the context's commands directory.
A ResolvedCommand
object.
Readonly
throwStatic
prepareCreate a new Context
instance and automatically prep it for execution.
Readonly
clientThe standard streams client.
Readonly
commandsThe path to the directory containing command modules.
Readonly
commandThe command string to be executed.
Readonly
hooksThe hooks emitter.
Readonly
pluginsMetadata about the plugins that will be used during preparation and execution.
The command lifecycle manager.
The
Context
serves as the orchestrator for the entire command lifecycle. It is responsible for initializing the CLI environment, resolving commands, parsing options, and managing execution flow. It ensures that all aspects of the CLI are prepared and ready before any action is taken, establishing a predictable and stable execution environment.Philosophy:
Context
offers explicit control over the command execution process, allowing for extensibility and customization without sacrificing predictability.Context
focuses on the setup and execution environment, whileState
manages the actual progression and state changes during command execution. This separation ensures that each module only handles its designated responsibilities, making the system easier to maintain and extend.Scope: