API Overview
Last updated:
API Overview
Complete API reference for Cerebro CLI framework.
Core API
createCerebro()
Create a new CLI instance:
function createCerebro<T extends Console = Console>(
name: string,
options?: CliOptions<T>
): Cerebro<T>Parameters:
name- CLI application nameoptions- Configuration options (optional)
Returns: Configured Cerebro instance
Example:
const cli = createCerebro("my-cli", {
packageName: "my-cli",
packageVersion: "1.0.0",
});Cerebro Class
Main CLI class with the following methods:
addCommand()
Register a command:
cli.addCommand(command: Command): voiduse()
Register a plugin:
cli.use(plugin: Plugin): voidrun()
Execute the CLI:
await cli.run(argv?: string[]): Promise<void>setDefaultCommand()
Set default command:
cli.setDefaultCommand(name: string): voidgetCommands()
Get all registered commands:
cli.getCommands(): Map<string, Command>Built-in Commands
HelpCommand- Display help textVersionCommand- Show versionCompletionCommand- Shell completionReadmeCommand- Generate README
Built-in Plugins
errorHandlerPlugin- Error handlingruntimeVersionCheckPlugin- Version validationupdateNotifierPlugin- Update notifications
Type Definitions
Command- Command definition interfacePlugin- Plugin definition interfaceToolbox- Execution context interfaceCliOptions- CLI configuration optionsOptionDefinition- Option definition interfaceArgumentDefinition- Argument definition interfaceEnvDefinition- Environment variable definition
Constants
VERBOSITY_QUIET- Quiet output levelVERBOSITY_NORMAL- Normal output levelVERBOSITY_VERBOSE- Verbose output levelVERBOSITY_DEBUG- Debug output level