An open API service indexing awesome lists of open source software.

https://github.com/dymmond/sayer

The Modern Python CLI Framework
https://github.com/dymmond/sayer

attrs click command-line dataclass msgspec pydantic rich rich-text-editor sayer serialization

Last synced: 7 months ago
JSON representation

The Modern Python CLI Framework

Awesome Lists containing this project

README

          

# Sayer


Sayer logo


Fast. Scalable. Elegant. Command the CLI like a boss. ๐Ÿง™โ€โ™‚๏ธ



Test Suite


Package version


Supported Python versions

---

**Documentation**: [https://sayer.dymmond.com](https://sayer.dymmond.com) ๐Ÿ“š

**Source Code**: [https://github.com/dymmond/sayer](https://github.com/dymmond/sayer)

**The official supported version is always the latest released**.

---

## ๐Ÿค” What is Sayer?

Sayer is a modern, async-native Python CLI framework built for developers who want more:

- More structure.
- More power.
- More expressiveness.

Less boilerplate. Less headache. Less "why doesn't this just work?".

Designed to scale from weekend scripts to enterprise-grade CLI suites โ€” with a touch of magic.

---

## ๐Ÿ“ฆ Installation

**Using [pip](https://pip.pypa.io/):**

```bash
pip install sayer
```

**Or with [uv](https://github.com/astral-sh/uv) (blazing fast):**

```bash
uv pip install sayer
```

---

## ๐Ÿงฉ Features

* โœ… Fully async support out-of-the-box
* โœ… Param metadata via `Option(...)`, `Argument(...)`, `Env(...)` โ€” inspired by the best
* โœ… Declarative CLI building with decorators
* โœ… Built-in middleware system (yes, for CLI!)
* โœ… Shared app state and lifecycle management
* โœ… Terminal-rich output via `rich`
* โœ… Easy testing with `SayerTestClient`
* โœ… Flexible help and docs rendering
* โœ… Clean project scaffolding, sensible defaults
* โœ… 100% type annotated.

---

## ๐Ÿ”ฅ Why Sayer?

| Feature | Sayer | Notes |
| --------------------- | ------------ | --------------------------------- |
| Async Support | โœ… Yes | Truly async from top to bottom |
| Param Metadata | โœ… Yes | With rich options, env vars, etc. |
| Middleware Support | โœ… Yes | Per-command, app-wide, scoped |
| Lifecycle Hooks | โœ… Yes | `on_startup`, `on_shutdown` |
| State Management | โœ… Yes | Like a Flask `g` but better |
| Testability | โœ… Yes | CLI client for unit tests |
| Output Styling | โœ… Yes | Built-in `rich` integration |
| Based on Modern Tools | โœ… Hatch + UV | Modern dev setup from day 1 |
| Full Typing | โœ… Yes | Mypy + Ruff compliant |
| Fun to Use? | ๐Ÿ•บ Extremely | Let the code dance with you |

---

## ๐Ÿš€ Getting Started

Create your first CLI app:

```python
from sayer import Sayer, Option

app = Sayer()

@app.command()
def hello(name: str = Option(..., help="Your name")):
"""Say hello to someone"""
print(f"Hello, {name}!")

if __name__ == "__main__":
app()
```

Run it:

```bash
$ python app.py hello --name Ada
Hello, Ada!
```

---

## ๐Ÿงช Testing

```bash
hatch run test:test
```

Or with pytest:

```bash
pytest -v
```

---

## ๐Ÿ“š Documentation

Full docs available at: [https://sayer.dymmond.com](https://sayer.dymmond.com)

Youโ€™ll find:

* Full API reference
* Command examples
* Parameter deep dives
* Middleware patterns
* Configuration strategies
* ... and some fun easter eggs ๐Ÿฃ