hexastack-cli
Typer and Rich presentation adapter for Hexastack: nested commands, aliases, piped outputs, and CQRS dispatching.
Part of the Hexastack Framework · Governed by Hexaqual.
1. Overview & Capabilities
hexastack-cli turns Hexastack CQRS commands and queries into intuitive, modern CLI applications:
- Nested Command Hierarchies: Nest subcommands naturally (
app user create,app db migrate) using@cli_group. - Command Aliases: Register multiple aliases for the same action (
app user new == app user create). - Feature Flag Gating: Gate CLI commands dynamically with
@feature_flag_command(...)and@cli_command(..., feature_flag=...). - Rich Formatted & CI-Friendly Output: Beautiful tables, panels, and spinners for interactive terminals; clean text/JSON streaming for CI/CD pipelines.
- Direct CQRS Dispatching: Declaratively expose domain commands (
@cli_command) and queries (@cli_query) with automatic parameter parsing and validation.
2. Package Anatomy & Key Components
hexastack_cli/
├── domain/ # CliContext, OutputFormat enum
├── adapters/ # Rich presenters, Typer command runners
└── infra/ # create_cli_app, CliBootstrapper (order=40), @cli_command, @cli_query, @cli_group, @feature_flag_command
Key Exports
| Category | Exports |
|---|---|
| Application Factory | create_cli_app, CliBootstrapper (order=30) |
| Decorators | @cli_command, @cli_query, @cli_group, @feature_flag_command |
| Presenters | RichTerminalPresenter, ConsolePresenter, TablePresenter, JsonPresenter |
| Testing & Demo Narration | CliNarrator, TerminalEvent |
3. Monorepo & Sibling Relationships
graph TD
subgraph UserInvocation ["CLI Invocations"]
INV["Terminal Commands & Scripts"]
end
subgraph CliLayer ["hexastack-cli"]
TYPER["Typer Application (Nested Groups & Aliases)"]
RICH["Rich Presenters (Tables, Panels, JSON)"]
SCAN["CLI Decorator Scanner (@cli_command, @cli_query)"]
end
subgraph CQRSExecution ["hexastack-cqrs"]
CBUS["CommandBusPort"]
QBUS["QueryBusPort"]
end
subgraph Kernel ["hexastack-core"]
DI["rodi.Container"]
end
INV --> TYPER
TYPER --> SCAN
SCAN -->|dispatches to| CBUS
SCAN -->|dispatches to| QBUS
SCAN --> RICH
TYPER -. resolves buses from DI .-> DI
Explicit Dependencies (Direct)
hexastack-core: Core kernel, DI container, and ports.hexastack-cqrs:CommandBusPortandQueryBusPortfor message dispatching.typer>=0.27.1: CLI command parser and shell completion.rich>=15.0.0: Terminal formatting, tables, and colors.
Implied / Behavioral Relationships (DI-Mediated)
- CQRS Integration: Dispatches CLI argument payloads directly into the application's command and query buses.
- Umbrella CLI: Consumed by the
hexastackumbrella package to power diagnostic commands (hexastack info,hexastack inspect registry,hexastack demo ping).
4. Installation
# Standalone install
pip install hexastack-cli
# Via umbrella package
pip install "hexastack[cli]"
5. Quickstart Example
from dataclasses import dataclass
from hexastack_core.infra.bootstrap import bootstrap
from hexastack_cqrs.domain.query import Query
from hexastack_cqrs.infra.decorators import query_handler
from hexastack_cli.infra.decorators import cli_query, cli_group
@dataclass(frozen=True)
class CheckStatusQuery(Query):
service_name: str
@query_handler(CheckStatusQuery)
class CheckStatusHandler:
def __call__(self, qry: CheckStatusQuery) -> dict:
return {"service": qry.service_name, "status": "ONLINE"}
# Expose query as a CLI command
cli_query("status", aliases=["st", "health"], help="Check status of a service")(
CheckStatusQuery
)
runtime = bootstrap(packages_to_scan=[__name__])
cli_app = runtime.get("cli_app")
Metadata
Release files for hexastack-cli 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hexastack_cli-0.8.0.tar.gz | 19.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hexastack_cli-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.9 kB
Release files / hexastack_cli-0.8.0.tar.gz
| Download URL | hexastack_cli-0.8.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c18fcccf880bf737f984661db0c279d2e1dd49b5d99045bd5f3a13f5cb7b20bd
|
|
BLAKE2b-256 checksum How to use checksums |
92fe416d05116eadf0c4aba4ed5fb53bbaa1dcd47478da76155c88ae77aae2ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hexastack_cli-0.8.0-py3-none-any.whl
| Download URL | hexastack_cli-0.8.0-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2beed9913968e20aaaae037bfcb4c62bed9064dfc32c34e6e16b64fcde26adea
|
|
BLAKE2b-256 checksum How to use checksums |
1b007e1d5fe0ec37df97ac13cfd4a015b96b79ed7061f8b5231f130d451e8a81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|