Protocols
Section titled “Protocols”CLIApplicationProtocol
Section titled “CLIApplicationProtocol”Protocol for a top-level CLI application.
A CLIApplication owns a CLIRunnerProtocol and manages the
full lifecycle of a CLI process: configuration loading, provider boot,
command dispatch, and shutdown.
property runner() -> CLIRunnerProtocol
The underlying command runner.
async def boot() -> None
Start the application, boot providers, and prepare for dispatch.
async def shutdown() -> None
Tear down resources and exit cleanly.
CLIRunnerProtocol
Section titled “CLIRunnerProtocol”Protocol for objects that can run CLI commands.
A CLIRunner discovers registered CommandProtocol implementations
and dispatches invocations based on the command name. Implementations may
wrap Click, Typer, argparse, or any other CLI framework.
def run(argv: list[str] | None = None) -> int
Parse argv (or sys.argv) and dispatch to the matching command.
| Parameter | Type | Description |
|---|---|---|
argv | list[str] | None | Argument vector to parse. Defaults to `sys.argv[1:]`. |
| Type | Description |
|---|---|
| int | Exit code (0 for success, non-zero for failure). |
def register_command(command: CommandProtocol) -> None
Register a command with this runner.
| Parameter | Type | Description |
|---|---|---|
command | CommandProtocol | A CommandProtocol implementation to register. |
CommandProtocol
Section titled “CommandProtocol”Protocol for CLI command implementations.
def execute( args: list[str], options: dict[str, Any] ) -> int
Execute the command.
| Parameter | Type | Description |
|---|---|---|
args | list[str] | Positional arguments |
options | dict[str, Any] | Parsed options dictionary |
| Type | Description |
|---|---|
| int | Exit code (0 for success) |
property name() -> str
Command name.
property description() -> str
Command description.
def get_help() -> str
Get help text for the command.
| Type | Description |
|---|---|
| str | Help text |
Classes
Section titled “Classes”CLIConfig
Section titled “CLIConfig”
CLIModule
Section titled “CLIModule”CLI command registration and configuration.
Call configure to configure the CLI provider.
Usage
from quadkit.cli.config import CLIConfig
@module( imports=[CLIModule.configure(CLIConfig(...))])class AppModule(Module): passfrom quadkit.cli.config import CLIConfig
@module( imports=[CLIModule.configure(CLIConfig(...))])class AppModule(Module): passdef configure( cls, config: Any | None = None ) -> DynamicModule
Create a CLIModule with explicit configuration.
| Parameter | Type | Description |
|---|---|---|
config | Any | None | CLIConfig or `None` for framework defaults. |
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule descriptor. |
def stub( cls, config: Any = None ) -> DynamicModule
Return a no-op CLIModule for testing.
Registers the CLI provider with default configuration. No commands are registered by default.
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule with default CLI configuration. |
OutputManager
Section titled “OutputManager”Unified output manager for all CLI commands.
def __init__( *, json_mode: bool = False, quiet: bool = False, debug: bool = False, no_color: bool = False ) -> None
def success( message: str, data: dict[str, Any] | None = None ) -> None
Print a success message.
def error( message: str, hint: str | None = None ) -> None
Print an error message. Shown even in quiet mode.
def warning(message: str) -> None
Print a warning message.
def info(message: str) -> None
Print an informational message.
def table( headers: list[str], rows: list[list[str]] ) -> None
Print tabular data.
def key_value(data: dict[str, Any]) -> None
Print key-value pairs.
def cli_error(err: CliError) -> None
Render a structured CLIError with causes and suggestions.
def debug_msg(message: str) -> None
Print a debug message (only shown in debug mode).
def print( *args: Any, **kwargs: Any ) -> None
Pass-through to Rich console.print for one-off needs.
Functions
Section titled “Functions”find_config
Section titled “find_config”
def find_config( *, explicit_path: Path | None = None, start_dir: Path | None = None ) -> Path
| Parameter | Type | Description |
|---|---|---|
explicit_path | Path | None | If given, use this path directly. |
start_dir | Path | None | Directory to start searching from (default: CWD). |
| Type | Description |
|---|---|
| Path | Resolved Path to the config file. |
| Exception | Description |
|---|---|
| ConfigNotFoundError | If no config file is found. |
load_config_yaml
Section titled “load_config_yaml”
def load_config_yaml(path: Path) -> dict[str, Any]
Exceptions
Section titled “Exceptions”CliError
Section titled “CliError”Base exception for quadkit-cli operations.
def __init__( message: str | None = None, causes: list[str] | None = None, suggestions: list[str] | None = None, **kwargs: Any ) -> None
Initialize CLI error.
| Parameter | Type | Description |
|---|---|---|
message | str | None | Human-readable error message. |
causes | list[str] | None | List of potential causes for the error. |
suggestions | list[str] | None | List of suggestions to resolve the error. **kwargs: Additional keyword arguments passed to parent. |
ConfigNotFoundError
Section titled “ConfigNotFoundError”Raised when application.yaml configuration file is not found.
ProviderNotInstalledError
Section titled “ProviderNotInstalledError”Raised when a required provider package is not installed.
def __init__(provider: str) -> None
Initialize provider not installed error.
| Parameter | Type | Description |
|---|---|---|
provider | str | Name of the missing provider. |