Program
Hierarchy
- CommandManager<ProgramOptions>
- Program
Index
Events
readonlyonAfterRegister
readonlyonAfterRender
Called after a component has rendered.
readonlyonAfterRun
Called after the program and command have been ran.
readonlyonBeforeRegister
Called before a command has been registered.
readonlyonBeforeRender
Called after a command has run but before a component will render.
readonlyonBeforeRun
Called before the program and command will run.
readonlyonCommandFound
Called when a command has been found after parsing argv.
readonlyonCommandNotFound
Called when a command wasn't found after parsing argv.
readonlyonExit
Called when the exit() handler is executed but before the process exits.
readonlyonHelp
Called when the help menu is rendered.
Other
constructor
readonlyoptions
Validated and configured options.
readonlystreams
blueprint
categories
Define option and command categories to supply to the running command, or the program itself.
configure
Set an options object by merging the new partial and existing options with the defined blueprint, while running all validation checks. Freeze and return the options object.
object.configure({ name: 'Boost' });
object.configure((prevOptions) => ({
nestedObject: {
...prevOptions.nestedObject,
some: 'value',
},
}));
default
Register a command and its canonical path as the default command. A default command should be used when stand-alone binary is required.
exit
Exit the program with an error code. Should be called within a command or component.
getCommand
Return a command by registered path, or
null
if not found.Type parameters
- O: object = {}
- P: PrimitiveType[] = ArgList
getCommandPaths
Return a list of all registered command paths (including aliases).
middleware
Define a middleware function to apply to the argv list or args object.
parse
Parse the arguments list according to the number of commands that have been registered.
Type parameters
- O: GlobalOptions
- P: PrimitiveType[] = ArgList
register
Register a command and its canonical path (must be unique), otherwise an error is thrown.
renderElement
Render a React element with Ink and output to the configured streams.
run
Run the program in the following steps:
- Apply middleware to argv list.
- Parse argv into an args object (of options, params, etc).
- Determine command to run, or fail.
- Run command and render output.
- Return exit code.
runAndExit
Run the program and also set the process exit code.
Called after a command has been registered.