Metadata-Version: 2.5
Name: cotyper
Version: 0.15.0
Summary: Wrapper around Typer to create command line interfaces for Pydantic models
Project-URL: Homepage, https://gitlab.opencode.de/lgln/cotyper
Project-URL: Documentation, https://cotyper-065160.usercontent.opencode.de/
Project-URL: Source, https://gitlab.opencode.de/lgln/cotyper
Project-URL: Issues, https://gitlab.opencode.de/lgln/cotyper/-/issues
Project-URL: Changelog, https://gitlab.opencode.de/lgln/cotyper/-/blob/master/CHANGELOG.md
Author-email: Lukas Sanner <lukas.sanner@lgln.niedersachsen.de>
License-Expression: MIT
License-File: LICENSE
Keywords: cli,command-line,configuration,pydantic,typer
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Framework :: Pydantic :: 2
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: User Interfaces
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: docstring-parser>=0.16
Requires-Dist: pydantic>=2.11.5
Requires-Dist: rich>=13.8.0
Requires-Dist: tomli>=2.0.1; python_version < '3.11'
Requires-Dist: typer<0.28,>=0.27.2
Requires-Dist: typing-extensions>=4.12.2
Provides-Extra: dev
Requires-Dist: pre-commit>=4.2.0; extra == 'dev'
Requires-Dist: pytest>=8.4.1; extra == 'dev'
Requires-Dist: ruff>=0.12.4; extra == 'dev'
Requires-Dist: ty>=0.0.84; extra == 'dev'
Provides-Extra: loguru
Requires-Dist: loguru>=0.7.3; extra == 'loguru'
Provides-Extra: rich
Provides-Extra: test
Requires-Dist: pytest-cov>=6.1.1; extra == 'test'
Requires-Dist: pytest>=8.0; extra == 'test'
Requires-Dist: pyyaml>=6.0; extra == 'test'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# CoTyper

[![CI Status](https://gitlab.opencode.de/lgln/cotyper/badges/master/pipeline.svg)](https://gitlab.opencode.de/lgln/cotyper/-/pipelines)
[![Coverage](https://gitlab.opencode.de/lgln/cotyper/badges/master/coverage.svg)](https://gitlab.opencode.de/lgln/cotyper/-/commits/master)
[![Docs](https://img.shields.io/badge/docs-online-blue)](https://cotyper-065160.usercontent.opencode.de/)
[![PyPI](https://img.shields.io/pypi/v/cotyper?label=PyPI%20version)](https://pypi.org/project/cotyper/)
[![Downloads](https://img.shields.io/pypi/dm/cotyper)](https://pypi.org/project/cotyper/)

**CoTyper** turns functions that take (nested) [Pydantic](https://docs.pydantic.dev) models
into [Typer](https://typer.tiangolo.com) command line interfaces. Every model field becomes
its own option, and the parsed values are folded back into validated model instances before
your function is called.

**Co**Typer, since you add a lot of _co_ in category theory.

📖 **Documentation: <https://cotyper-065160.usercontent.opencode.de/>**

> [!NOTE]
> CoTyper is in early development. The API may still change between minor versions.

## Installation

```shell
pip install cotyper
# or
uv add cotyper
```

The optional extra `loguru` adds a loguru logging backend: `pip install "cotyper[loguru]"`.
See [Installation](https://cotyper-065160.usercontent.opencode.de/installation/) for building from source.

## Quick start

```python
from pydantic import BaseModel
from cotyper import App

app = App()


class Database(BaseModel):
    host: str = "localhost"
    port: int = 5432


@app.struct_command("connect")
def connect(db: Database):
    print(f"Connecting to {db.host}:{db.port}")


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

```console
$ python app.py --db-host example.org --db-port 6543
Connecting to example.org:6543
```

## Learn more

- [Tutorial](https://cotyper-065160.usercontent.opencode.de/tutorial/) – build a CLI step by step
- [Guide](https://cotyper-065160.usercontent.opencode.de/guide/) – naming rules, supported types,
  config files, `unfold_cls`, optional and list fields, logging
- [API Reference](https://cotyper-065160.usercontent.opencode.de/api/)
- [`examples/`](examples/) – runnable scripts, e.g. `uv run examples/extensive.py --help`

## Development

```shell
uv run pytest                                  # run the tests
uv run --only-group docs mkdocs serve          # preview the docs locally
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute.

## License

MIT License
