Metadata-Version: 2.4
Name: sonnet-cli
Version: 0.2.1
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

Typer and rich building blocks for the command-line side of a sonnet-server
application: a base app, a database command group, a resource command factory
and terminal widgets.

**It is a library, not a binary.** There is no `[project.scripts]` entry and no
`sonnet-cli` command; installing it puts nothing on your `PATH`. Your
application defines its own Typer app and its own entry point, and mounts these
pieces into it.

Version 0.2.0.

## What it provides

- **`sonnet_cli.commands.db`** -- a `db check` / `db upgrade` group that runs
  against the application's own Alembic chain.
- **`sonnet_cli.resource_cli`** -- uniform `list` / `get` / `set` commands over
  a `ResourceSpec`-backed resource, talking to the repository directly with no
  HTTP server involved.
- **`sonnet_cli.checks`** -- a readiness-pipeline runner and the database
  pipeline builders behind the `db` commands.
- **`sonnet_cli.multiselect`** -- an arrow-key checkbox picker with a numbered
  fallback when stdin is not a TTY.
- **`sonnet_cli.utils`** -- the shared rich console and path helpers that exit
  cleanly.
- **`sonnet_cli.app`** -- a ready-made base Typer app with the `db` group
  mounted, for cases where you do not need your own callback.

`python -m sonnet_cli db check` exists so the commands can be exercised
in-tree during development. It is not an operator interface.

## Install

```bash
uv add sonnet-cli
```

Depends on typer, rich, [`sonnet-server`](../sonnet-server/README.md) and
[`sonnet-core`](../sonnet-core/README.md). Adding it to an application that
already depends on `sonnet-server` costs two terminal libraries and nothing
else. The only extra is `dev`.

## Usage

Define your own Typer app, register your services in the callback, and mount
the groups you want:

```python
import typer
from sonnet_cli.commands import db
from sonnet_core.services.registry import get_service_registry

from example_server.services.di import register_all_services

app = typer.Typer(name="example-server-cli", no_args_is_help=True)


@app.callback()
def main_callback() -> None:
    registry = get_service_registry()
    register_all_services(registry)


app.add_typer(db.app, name="db")
```

Your `[project.scripts]` entry points at that app. The commands still need
settings loaded and services registered before they run -- that bootstrap is
your application's job, and the usage guides walk through it.

## Documentation

- **Usage** -- [`docs/usage/index.md`](docs/usage/index.md)
- **Design** -- [`docs/design/index.md`](docs/design/index.md)
- **Workspace** -- [`../../docs/README.md`](../../docs/README.md)

## License

Apache 2.0 -- see [LICENSE.md](../../LICENSE.md).
