Skip to main content

Function annotations -> argparse parser

Project description


A dead simple way to generate a CLI (via argparse) using Python 3.7+ function annotations.

Right now it's nearly featureless, but it does support subcommands! See for more details.


python3.7 -m pip install --user clii


from clii import App, Arg

cli = App(description=__doc__)

def say_hello(name: str, 
              greeting: Arg('-g', str, 'Greeting to use') = 'hello'):
    """Sum two numbers."""
    print(f'{greeting}, {name}')

if __name__ == '__main__': 

gives you

$ ./ -h

usage: [-h] [--greeting GREETING] name

Greet somebody.

positional arguments:

  optional arguments:
    -h, --help            show this help message and exit
    --greeting GREETING, -g GREETING
                            Greeting to use. Default: hello

Project details

Download files

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

Files for clii, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size clii-0.1.1-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size clii-0.1.1.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page