Skip to main content

Framework for writing CLI application quickly

Project description

Clea - A lightweight framework for creating CLI applications in python

Clea is uses type annotations to generate the command/group defintions and parse the arguments at the runtime. To start with clea run

pip3 install clea

Define you first command using

from typing_extensions import Annotated

from clea.params import Integer
from clea.wrappers import command

@command
def add(
    n1: Annotated[int, Integer()],
    n2: Annotated[int, Integer()],
) -> None:
    """Add two numbers"""

    print(f"Total {n1 + n2}")

Invoke the command at runtime using

from clea.runner import run

if __name__ == "__main__":
    run(cli=add)

The example is taken from add.py in the examples folder.

You can check the command definition using

$ python add.py --help

Usage: add [OPTIONS] N1 N2

        Add two numbers

Options:

    --help                        Show help and exit.

Execute the command using

$ python add.py 2 3

Total 5

Read more about the usage of clea in the docs

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

clea-0.1.0rc4.tar.gz (20.7 kB view hashes)

Uploaded Source

Built Distribution

clea-0.1.0rc4-py3-none-any.whl (22.8 kB view hashes)

Uploaded Python 3

Supported by

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