Optional
afterA hook that runs once all commands have been called or when context.end()
is called.
The final result.
Override the final result.
The state object.
Optional
afterA hook that runs after parsing the command string.
The command's context object.
The resulting parsed options.
Override the parsed options.
The parsed option values.
Optional
afterA hook that runs after importing command modules.
Add additional resolved commands to the context.
After each command is resolved, it's options config is merged with the
context's existing options config so that context is always up to date in
the beforeResolveNext
hook. Because of this, resolved commands
can't be replaced once resolved, only added to. If you need to manually
set the resolved commands, you can use the beforeResolve
hook to
do so.
The command's context object.
The resolved commands.
Optional
beforeA hook that runs before executing the context.end()
function.
The data that will be returned.
Override the data that will be returned.
The new data.
The state object.
Optional
beforeA hook that runs before calling the first command.
The initial data that was passed to the state.
Override the state's initial data.
The new initial data.
Set the final result and skip execution.
Skip execution.
The state object.
Optional
beforeA hook that runs before executing the context.next()
function.
The data that will be passed to the next command.
The next command that will be executed.
Override the data that will be passed to the next command.
The new data.
Override the next command that will be executed.
The new next command.
The state object.
Optional
beforeA hook that runs before parsing the command string using the options config from plugins and imported command modules.
The command string that was passed to the CLI.
The command's context object.
The context's final options config from all plugins and resolved commands.
Override the context's configured parse function.
The new parse function.
Manually set the parsed options and skip parsing.
The parsed option values.
Skip parsing the command.
Optional
beforeA hook that runs before attempting to locate and import command modules.
Add additional resolved commands to the context.
The command string that was passed to the CLI.
The path to the directory where the commands live.
The command's context object.
Override the context's configured parse function.
The new parse function.
Override the context's configured resolve function.
The new resolve function.
Skip resolving the command.
Optional
commandThe command string or array to be parsed and executed. If not provided, it defaults to system arguments.
Optional
commandsA directory path containing command modules.
"<cwd>/commands" || "<caller-dir>/commands"
Optional
initialInitial context or data to pass to commands during execution.
Optional
onA hook that runs whenever an error is thrown.
The command's context object.
The error that was thrown.
Prevent the error from being thrown.
Override the error that will be thrown.
The new error.
Optional
onA hook that runs whenever a plugin or command intends to exit the process.
Prevent the process from exiting.
The exit code.
The command's context object.
Optional
message?: anyAn optional message to log.
Override the exit code.
The new exit code.
Override the message to log.
The new message.
Optional
optionsOptions to include in the context.
Optional
pluginsAn array of plugins that can modify or augment the behavior of commands.
Options for the
run
function.