declinate


Namedeclinate JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummaryCLI generator.
upload_time2025-01-11 16:20:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseApache-2.0
keywords cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://gitlab.com/ternaris/declinate/badges/master/pipeline.svg
   :target: https://gitlab.com/ternaris/declinate/-/commits/master
   :alt: pipeline status

.. image:: https://gitlab.com/ternaris/declinate/badges/master/coverage.svg
   :target: https://gitlab.com/ternaris/declinate/-/commits/master
   :alt: coverage report

.. image:: https://img.shields.io/pypi/pyversions/declinate
   :alt: 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:

.. code-block:: python

   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 <https://ternaris.gitlab.io/declinate/>`_ for further information.

.. end documentation


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 <https://gitlab.com/ternaris/declinate/-/blob/master/CONTRIBUTING.rst>`_.

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 <https://ternaris.com>`_.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "declinate",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "cli",
    "author": null,
    "author_email": "Ternaris <team@ternaris.com>",
    "download_url": "https://files.pythonhosted.org/packages/4d/50/2a234623765991b572b626ff78a9d5e6b8cc3eaea7631f2408e46f9601d4/declinate-0.0.5.tar.gz",
    "platform": null,
    "description": ".. image:: https://gitlab.com/ternaris/declinate/badges/master/pipeline.svg\n   :target: https://gitlab.com/ternaris/declinate/-/commits/master\n   :alt: pipeline status\n\n.. image:: https://gitlab.com/ternaris/declinate/badges/master/coverage.svg\n   :target: https://gitlab.com/ternaris/declinate/-/commits/master\n   :alt: coverage report\n\n.. image:: https://img.shields.io/pypi/pyversions/declinate\n   :alt: python versions\n\n=========\nDeclinate\n=========\n\nDeclinate is a command line interface generator. It is a development tool that parses function type annotations and docstrings to generate Python CLIs:\n\n- It uses **builtin language features** to describe CLIs.\n- Declinate is **not a runtime dependency**, it compiles to vanilla Python argparse calls during development.\n- Generated CLIs use lazy imports, resulting in **extremely fast startup time**.\n- **Command completion** for Bash and Zsh are added by default.\n\n\nGetting started\n===============\n\nDeclinate is published on PyPI and does not have any special dependencies. Simply install with pip::\n\n   pip install declinate\n\n\nThe package installs the ``declinate`` command to generate a CLI for a python package::\n\n   # Print python code to stdout.\n   declinate generate example_pkg\n\n   # Write cli.py module in example_pkg package.\n   declinate generate -w example_pkg\n\n\nOf course, declinate's own CLI is \"self-hosting\" and can recreate itself::\n\n   declinate generate declinate\n\n\nDeclinate 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:\n\n.. code-block:: python\n\n   def check(package: str) -> int:\n       \"\"\"Check if generated cli is up to date.\n\n       Args:\n           package: Name of the Python package.\n\n       Returns:\n           0 if success.\n\n       \"\"\"\n       if res := check_package(package):\n           print(res)\n           return 1\n       return 0\n\n\nTake a closer look at the different example CLIs in the tests package that demonstrate the various features.\n\n\nDocumentation\n=============\n\nRead the `documentation <https://ternaris.gitlab.io/declinate/>`_ for further information.\n\n.. end documentation\n\n\nContributing\n============\n\nThank you for considering to contribute to declinate.\n\nTo submit issues or create merge requests please follow the instructions provided in the `contribution guide <https://gitlab.com/ternaris/declinate/-/blob/master/CONTRIBUTING.rst>`_.\n\nBy contributing to declinate you accept and agree to the terms and conditions laid out in there.\n\n\nDevelopment\n===========\n\nClone the repository and setup your local checkout::\n\n   git clone https://gitlab.com/ternaris/declinate.git\n\n   cd declinate\n   python -m venv venv\n   . venv/bin/activate\n\n   pip install -r requirements-dev.txt\n   pip install -e .\n\n\nThis 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::\n\n   pytest\n\n\nTo build the documentation from its source run sphinx-build::\n\n   sphinx-build -a docs public\n\n\nThe entry point to the local documentation build should be available under ``public/index.html``.\n\n\nSupport\n=======\n\nProfessional support is available from `Ternaris <https://ternaris.com>`_.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CLI generator.",
    "version": "0.0.5",
    "project_urls": {
        "Changelog": "https://gitlab.com/ternaris/declinate/-/blob/master/CHANGES.rst",
        "Documentation": "https://ternaris.gitlab.io/declinate",
        "Homepage": "https://gitlab.com/ternaris/declinate",
        "Issues": "https://gitlab.com/ternaris/declinate/issues",
        "Source": "https://gitlab.com/ternaris/declinate"
    },
    "split_keywords": [
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af438f6d3f9aa0bb96ea868ceb1cee1a60bf2f50662f595da202ca0fde042bcb",
                "md5": "594c0d33270ddd31f20046e63b0339b2",
                "sha256": "1de8abfc0ec8c4b9ef622db9a0fe4c5aa23ba64ce81fbcfbadd95856b6f736d0"
            },
            "downloads": -1,
            "filename": "declinate-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "594c0d33270ddd31f20046e63b0339b2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 20687,
            "upload_time": "2025-01-11T16:20:00",
            "upload_time_iso_8601": "2025-01-11T16:20:00.778995Z",
            "url": "https://files.pythonhosted.org/packages/af/43/8f6d3f9aa0bb96ea868ceb1cee1a60bf2f50662f595da202ca0fde042bcb/declinate-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d502a234623765991b572b626ff78a9d5e6b8cc3eaea7631f2408e46f9601d4",
                "md5": "5bab80a61e0889bd38aaa57b4f09667a",
                "sha256": "818aff9a4eca1c2abf411c19f9a831594a13bb891161417d5defbeabc1dd59cb"
            },
            "downloads": -1,
            "filename": "declinate-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "5bab80a61e0889bd38aaa57b4f09667a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 68190,
            "upload_time": "2025-01-11T16:20:02",
            "upload_time_iso_8601": "2025-01-11T16:20:02.190779Z",
            "url": "https://files.pythonhosted.org/packages/4d/50/2a234623765991b572b626ff78a9d5e6b8cc3eaea7631f2408e46f9601d4/declinate-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-11 16:20:02",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "ternaris",
    "gitlab_project": "declinate",
    "lcname": "declinate"
}
        
Elapsed time: 0.44637s