Skip to main content
pipeline status coverage report python versions

Declinate

Declinate is a command line interface generator. It is a development tool that parses function type annotations and docstrings to generate Python CLIs:

  • It uses builtin language features to describe CLIs.

  • Declinate is not a runtime dependency, it compiles to vanilla Python argparse calls during development.

  • Generated CLIs use lazy imports, resulting in extremely fast startup time.

  • Command completion for Bash and Zsh are added by default.

Getting started

Declinate is published on PyPI and does not have any special dependencies. Simply install with pip:

pip install declinate

The package installs the declinate command to generate a CLI for a python package:

# Print python code to stdout.
declinate generate example_pkg

# Write cli.py module in example_pkg package.
declinate generate -w example_pkg

Of course, declinate’s own CLI is “self-hosting” and can recreate itself:

declinate generate declinate

Declinate expects the python package to declare its command and subcommands in a module named declinate.py. Here is how declinate’s own “check” subcommand is declared:

def check(package: str) -> int:
    """Check if generated cli is up to date.

    Args:
        package: Name of the Python package.

    Returns:
        0 if success.

    """
    if res := check_package(package):
        print(res)
        return 1
    return 0

Take a closer look at the different example CLIs in the tests package that demonstrate the various features.

Documentation

Read the documentation for further information.

Contributing

Thank you for considering to contribute to declinate.

To submit issues or create merge requests please follow the instructions provided in the contribution guide.

By contributing to declinate you accept and agree to the terms and conditions laid out in there.

Development

Clone the repository and setup your local checkout:

git clone https://gitlab.com/ternaris/declinate.git

cd declinate
python -m venv venv
. venv/bin/activate

pip install -r requirements-dev.txt
pip install -e .

This creates a new virtual environment with the necessary python dependencies and installs declinate in editable mode. The declinate code base uses pytest as its test runner, run the test suite by simply invoking:

pytest

To build the documentation from its source run sphinx-build:

sphinx-build -a docs public

The entry point to the local documentation build should be available under public/index.html.

Support

Professional support is available from Ternaris.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

declinate-0.0.7.tar.gz (117.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

declinate-0.0.7-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file declinate-0.0.7.tar.gz.

File metadata

  • Download URL: declinate-0.0.7.tar.gz
  • Upload date:
  • Size: 117.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for declinate-0.0.7.tar.gz
Algorithm Hash digest
SHA256 baa47db69913a3f5b6ea2d232babc8d5525b188182b59e9b9ba673cf484276bb
MD5 7a3230de6ab1869fa0211546f65f05e5
BLAKE2b-256 b41a781dc1e6192a772c7262b728a521bdeebaa556755ab26c5265a1d07d8d8c

See more details on using hashes here.

File details

Details for the file declinate-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: declinate-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for declinate-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d8d64677df3b442cf0eada73bba2f9024605888b33ddb2919d9f2e17e8cc5ec7
MD5 29255183d4d6d3cc96c6601c4133f906
BLAKE2b-256 1b648adbe5259ec642424a6f72969190eb51f5490450da33289b790c049d8608

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page