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 details)
Built Distribution
clii-0.1.1-py3-none-any.whl
(3.3 kB
view details)
File details
Details for the file clii-0.1.1.tar.gz
.
File metadata
- Download URL: clii-0.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/2.7.15+ Linux/4.15.0-66-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e78d3ec85a3506be3d2f7889b7055ddcf7a57de4a629e56332ea9d28f3d0569a |
|
MD5 | ed24881a5eddd0250d4c5c3d2fe34715 |
|
BLAKE2b-256 | d9605c506d049e8d7d141bb12935578ee3d88f2e2ab888abd5c7e45fad8c7688 |
File details
Details for the file clii-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: clii-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/2.7.15+ Linux/4.15.0-66-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29d2a245f64b66d81c82b063fc9504bc220ab12f16074a1a0f1d5df573091d3c |
|
MD5 | f25677d20f7e9a37701afb47a2352882 |
|
BLAKE2b-256 | 1571bb20d0f6dbc85bca0738fbc0d9b65a250ce646e0da4c2f84b308546a3bc9 |