Metadata-Version: 2.4
Name: sonnet-cli
Version: 0.2.0
Summary: Command-line interface library for sonnet-server applications
Author-email: Wolfgang Miller <wolfgang.miller@petrarca-labs.com>
License-Expression: Apache-2.0
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Requires-Python: <4.0,>=3.14
Description-Content-Type: text/markdown
Requires-Dist: typer>=0.24.1
Requires-Dist: rich>=13.8.0
Requires-Dist: sonnet-server>=0.4.0
Requires-Dist: sonnet-core>=0.1.0
Provides-Extra: dev
Requires-Dist: ruff>=0.3.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"

# sonnet-cli

The **command-line interface library** for sonnet-server applications.

> **Not a CLI application.** It ships no console script and is not run directly.
> Consuming apps (lauro, sestina, coco-rag, ...) import it to build *their own*
> command-line interfaces -- each app owns its Typer application and its
> `[project.scripts]` entry point. sonnet-cli provides the base app and the
> reusable command building blocks they assemble.

sonnet-cli depends on **sonnet-server** (concrete readiness checks, DI wiring)
and **sonnet-core** (`ResourceSpec`, `CrudRepository`, the readiness engine). It
is the CLI layer that sits *above* the server framework.

## Install

```bash
pip install sonnet-cli
```

## Contents

### Terminal building blocks

`typer` + `rich` + the standard library.

| Component | What |
|---|---|
| `sonnet_cli.app` | The base Typer application (the `db` command group mounted) |
| `sonnet_cli.multiselect` | Arrow-key checkbox picker with a numbered fallback when stdin is not a TTY |
| `sonnet_cli.utils` | Shared rich console and path helpers |

### Command-group factories

Pieces an app mounts into its own Typer app. These drive a sonnet-server
application.

| Component | What |
|---|---|
| `sonnet_cli.resource_cli` | Uniform `list` / `get` / `set` for a `ResourceSpec`-backed resource (talks to `CrudRepository` directly, no HTTP server) |
| `sonnet_cli.commands.db` | Database `check` / `upgrade`, given the app's Alembic config |
| `sonnet_cli.checks` | Readiness-pipeline runner and builders |

## Usage

A consuming app builds its own Typer application on top of `sonnet_cli.app`,
mounts the command groups it needs, and declares its own `[project.scripts]`
entry point. `ResourceSpec` is declared once (in `sonnet_core`) and consumed by
both `sonnet_cli.resource_cli` and sonnet-server's REST factory, so field policy
lives in one place across transports.

## Why a separate package

The CLI was a pure leaf inside `sonnet_server.cli` -- nothing in the server
runtime imported it -- consumed by several services with an identical surface.
Extracting it:

- lets sonnet-server drop its `typer` / `rich` dependency and be a pure
  web/server library;
- gives every sonnet-server app one shared CLI foundation instead of copies;
- makes the layering explicit (CLI on top of server + core).

It is a library, not a binary: there is no `sonnet-cli` command. A consuming app
is where a runnable CLI (and its `[project.scripts]`) lives.

## Licence

Apache-2.0
