Create a command line interface with minimal setup.
Command line interface (Cli) with a schema (Ma) - Clima
Installation
pip install clima
Requires Python 3.9.2+.
Quick example
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 →
.envfile → 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
--helpoutput - IDE completions ::
C.nameis typed asstr— completions and type checking work natively --verbose/--quietlogging :: Addverbose: boolorquiet: boolto Schema and get preconfigured logging- Undefined param warnings :: Unknown
--flagson the command line produce a clear warning versionsubcommand ::myscript versionprints the package version automatically- Config file support :: Declare defaults in an INI-style
.conffile keyed to your package name .envfile and env var support :: Schema fields are also read from environment variables and.envfiles- 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.
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.
Release files for clima 0.13.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clima-0.13.8.tar.gz | 38.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clima-0.13.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.4 kB
Release files / clima-0.13.8.tar.gz
| Download URL | clima-0.13.8.tar.gz |
|---|---|
| Size | 38.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a438d6aa59f70888122bdf131af011c053d22c827fc144cede678686c27de5a
|
|
BLAKE2b-256 checksum How to use checksums |
79602fb36b24f2ca05c072bd33b4b1563ad9c0ec00aa3f0d46e96aeb65930e00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.0 CPython/3.12.9 Darwin/24.6.0
|
Release files / clima-0.13.8-py3-none-any.whl
| Download URL | clima-0.13.8-py3-none-any.whl |
|---|---|
| Size | 48.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e176ec076fedf2864ca004c981d32ff8f590b069b910f3a3df56c543af3224d2
|
|
BLAKE2b-256 checksum How to use checksums |
dc908df3f1a09a8dcae1a5a4c873e0bfb5b2705a786b3cbf88554dc1b5dbde09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.0 CPython/3.12.9 Darwin/24.6.0
|