Kernel
The Ace command kernel for AdonisJS applications. This kernel extends the base Ace kernel with AdonisJS-specific functionality like dependency injection and application lifecycle management.Import
Constructor
Creates a new Ace kernel instance.The AdonisJS application instance
Example
Properties
Reference to the AdonisJS application instance
Inherited Methods
TheKernel class extends @adonisjs/ace Kernel and inherits all its methods:
handle()
Handle and execute a command with the provided arguments.Array of command line arguments (e.g.,
['make:controller', 'UserController'])Promise<any>
addLoader()
Register a command loader to lazy-load commands.A loader function or object that provides command metadata and loading logic
void
getCommand()
Get a command instance by name.The name of the command to retrieve
Command | undefined
getMainCommand()
Get the main command that is currently executing. Returns:Command | undefined
defineFlag()
Define a global flag that is available across all commands.The name of the flag
Configuration options for the flag including type, description, and default value
void
on()
Register an event listener for flag events.The flag name to listen for
Event handler function
void
shortcircuit()
Stop command execution and prevent further processing. Returns:symbol
Factory Function
createAceKernel()
Create and configure an Ace command kernel for AdonisJS applications with default loaders and flags.The AdonisJS application service instance
Optional specific command name for optimized loading
Kernel
Example
Features
- Automatically loads commands from
rcFile.commands - Sets up filesystem loader for application commands
- Defines global
--ansiand--helpflags - Configures flag listeners for colorful output and help display
See Also
- Command API - Create custom Ace commands
- Codemods API - Programmatically modify source files