Metadata-Version: 2.4
Name: clima
Version: 0.13.8
Summary: Command line interface (cli) boilerplate using a schema
License-File: AUTHORS
License-File: LICENSE
Keywords: cli,schema,boilerplate,cli-boilerplate,cli-schema,cli-tool,cli-tools,cli-interface,cli-interfaces,cli-application,cli-applications
Author: Joni Turunen
Author-email: rojun.itu@gmail.com
Requires-Python: >=3.9.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Provides-Extra: tabulate
Requires-Dist: bleach (>=6.2.0,<7.0.0)
Requires-Dist: cryptography (>=44.0.5)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0) ; python_version < "3.10"
Requires-Dist: python-dotenv (>=1.2.2,<2.0.0) ; python_version >= "3.10"
Requires-Dist: setuptools (>=78.1.1,<79.0.0)
Requires-Dist: tabulate (>=0.9.0,<0.10.0) ; extra == "tabulate"
Requires-Dist: wheel
Project-URL: Homepage, https://github.com/turuluu/clima.git
Description-Content-Type: text/markdown

<img src="https://raw.githubusercontent.com/turuluu/clima/master/docs/assets/clima.png" align="left" /> Create a command line interface with minimal setup.

[![PyPI](https://img.shields.io/pypi/v/clima)](https://pypi.org/project/clima/)
[![Python versions](https://img.shields.io/pypi/pyversions/clima)]()
[![PyPI license](https://img.shields.io/pypi/l/clima)]() 

# Command line interface (Cli) with a schema (Ma) - Clima

## Installation

```
pip install clima
```

Requires Python 3.9.2+.

## Quick example

```python
from clima import Schema

class S(Schema):
    place = 'Finland'

@S.cli
class Cli:
    def say_hi(self):
        print(f'Hi from {S.place}')
```

```
$ cli.py say_hi
Hi from Finland
$ cli.py say_hi --place 'Sweden'
Hi from Sweden
```

## Why Clima?

Clima eliminates CLI boilerplate: just define a `Schema` dataclass and a `Cli` class. Opinionated for convenience; Unlike click, typer, or argparse, clima gives you a built-in config cascade (CLI args → env vars → `.env` file → config file → defaults) with zero extra code. 

## Features

Schema fields double as CLI flags, environment variables, and config file keys automatically while providing help printout, default values and type casting.

- **Config cascade** :: CLI args → env vars → `.env` file → config file → defaults, resolved automatically
- **Type casting** :: Schema field annotations are used to cast string CLI/env values to the right type
- **Help from field comments** :: Docstrings on Schema fields act as `--help` output
- **IDE completions** :: `C.name` is typed as `str` — completions and type checking work natively
- **`--verbose` / `--quiet` logging** :: Add `verbose: bool` or `quiet: bool` to Schema and get preconfigured logging
- **Undefined param warnings** :: Unknown `--flags` on the command line produce a clear warning
- **`version` subcommand** :: `myscript version` prints the package version automatically
- **Config file support** :: Declare defaults in an INI-style `.conf` file keyed to your package name
- **`.env` file and env var support** :: Schema fields are also read from environment variables and `.env` files
- **Optional gpg secrets** :: Decrypt secrets via `pass` / gnupg if installed
- **Optional shortened tracebacks** :: Truncate python tracebacks into an opinionated format

## Documentation

Full documentation at [python-clima.readthedocs.io](https://python-clima.readthedocs.io/).

See and run the `examples/` directory for more usage patterns.

## AI Disclaimer

This work started in 2019 as my hobby project and continues as so. Claude was used to bridge gaps I had planned, but had not had the time to address.

Before merging to main and uploading to pypi the code is hand-vetted to find all code assistance related issues.

![Contributions ratios](./docs/assets/contributions.png)

