Engine Module API Reference¶
This section documents the internals of the engine
module in Bijux CLI.
bijux_cli.core.engine ¶
Provides the core runtime engine for the Bijux CLI.
This module defines the Engine
class, which is responsible for orchestrating the application's runtime environment after initial setup. Its key responsibilities include:
* Initializing and registering all default services with the Dependency
Injection (DI) container.
* Discovering, loading, and registering all external plugins.
* Providing a central method for dispatching commands to plugins.
* Managing the graceful shutdown of services.
The engine acts as the bridge between the CLI command layer and the underlying services and plugins.
Engine ¶
Engine(
di: Any = None,
*,
debug: bool = False,
fmt: OutputFormat = JSON,
quiet: bool = False,
)
Orchestrates the CLI's runtime services and plugin lifecycle.
Attributes:
-
_di
(DIContainer
) –The dependency injection container.
-
_debug
(bool
) –The debug mode flag.
-
_format
(OutputFormat
) –The default output format.
-
_quiet
(bool
) –The quiet mode flag.
-
_registry
(RegistryProtocol
) –The plugin registry service.
Initializes the engine and its core services.
This sets up the DI container, registers default services, and loads all discoverable plugins.
Parameters:
-
di
(Any
, default:None
) –An existing dependency injection container. If None, the global singleton instance is used. Defaults to None.
-
debug
(bool
, default:False
) –If True, enables debug mode for services.
-
fmt
(OutputFormat
, default:JSON
) –The default output format for services.
-
quiet
(bool
, default:False
) –If True, suppresses output from services.
Source code in src/bijux_cli/core/engine.py
run_command async
¶
Executes a plugin's command with a configured timeout.
Parameters:
-
name
(str
) –The name of the command or plugin to run.
-
*args
(Any
, default:()
) –Positional arguments to pass to the plugin's
execute
method. -
**kwargs
(Any
, default:{}
) –Keyword arguments to pass to the plugin's
execute
method.
Returns:
-
Any
(Any
) –The result of the command's execution.
Raises:
-
CommandError
–If the plugin is not found, its
execute
method is invalid, or if it fails during execution.
Source code in src/bijux_cli/core/engine.py
run_repl async
¶
shutdown async
¶
Gracefully shuts down the engine and all resolved services.
This method orchestrates the termination sequence for the application's runtime. It first attempts to flush any buffered command history to disk and then proceeds to shut down the main dependency injection container, which in turn cleans up all resolved services.
Returns:
-
None
(None
) –