Function annotations -> argparse parser
Project description
clii
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
test_clii.py
for more details.
Installation
python3.7 -m pip install --user clii
Usage
from clii import App, Arg
cli = App(description=__doc__)
@cli.main
def say_hello(name: str,
greeting: Arg('-g', str, 'Greeting to use') = 'hello'):
"""Sum two numbers."""
print(f'{greeting}, {name}')
if __name__ == '__main__':
cli.run()
gives you
$ ./test_hello.py -h
usage: test_hello.py [-h] [--greeting GREETING] name
Greet somebody.
positional arguments:
name
optional arguments:
-h, --help show this help message and exit
--greeting GREETING, -g GREETING
Greeting to use. Default: hello
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clii-0.1.1.tar.gz
(3.4 kB
view hashes)
Built Distribution
clii-0.1.1-py3-none-any.whl
(3.3 kB
view hashes)