Skip to main content

hexastack-cli

hexastack-cli

Typer and Rich presentation adapter for Hexastack: nested commands, aliases, piped outputs, and CQRS dispatching.

PyPI: hexastack-cli Python 3.13+ Coverage License: Apache 2.0

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/        # create_cli_app, Rich presenters, Typer command runners
└── infra/           # CliBootstrapper (order=30), @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: CommandBusPort and QueryBusPort for 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 hexastack umbrella 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")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hexastack_cli-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hexastack_cli-0.1.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file hexastack_cli-0.1.0.tar.gz.

File metadata

  • Download URL: hexastack_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hexastack_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de34c9569007c1bcdaf426a321190dc3b78e1d8d9778e32292807dc5f8aae789
MD5 052cafcad1d0bc4bf16c012dce85195f
BLAKE2b-256 0ad5599fbed961aee59a836be9f4efef99ef83991b647b69de1d2534be073981

See more details on using hashes here.

File details

Details for the file hexastack_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hexastack_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hexastack_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff4a9de30080e05d5e0baa6b9384172c640999c682ceec32c7452dfe8e303228
MD5 7f4cc97a01c89832a60f784d12818f62
BLAKE2b-256 01e2e6c9d347225c761e2d93255825d2ab377c4244913f30ae84f259ad7a7eeb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page