Skip to main content

CLI generator.

Project description

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.

Project details


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.6.tar.gz (71.8 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.6-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: declinate-0.0.6.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for declinate-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2355b23dbdafe3093a1360bcd7b9e52a255dbcd0bcc52e4342b7d7c649cba0fe
MD5 a968c5339fe62170e795c1b7621ab8d1
BLAKE2b-256 fa345de662ffe369ebf21df740fcabb0b83e02034ec7977d4956c69921674604

See more details on using hashes here.

File details

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

File metadata

  • Download URL: declinate-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for declinate-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 96aef831a972b4f087166fe4d8b57e3823f71336b8e96b9d231b565a4dee8537
MD5 fa322049d46bb566ee11e7aa64f009b7
BLAKE2b-256 ec11232836234e81202fd5ad4bd7e781892de025cc7a6fdeb3d7442f56944234

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page