Async cli client/commander framework
aiocli is a Python library for simple and lightweight async console runner.
Full compatibility with argparse module and highly inspired by aiohttp module.
Installation
Use the package manager pip to install aiocli.
pip install aiocli
Documentation
- Visit aiocli docs.
Usage
from logging import getLogger, Logger, StreamHandler
from os import getenv
from aiocli.commander import run_app, Application, Depends, State
app = Application(state={
'envs': {
'LOGGER_NAME': str(getenv('LOGGER_NAME', 'example_app')),
'LOGGER_LEVEL': str(getenv('LOGGER_LEVEL', 'INFO')),
}
})
def _get_logger(state: State) -> Logger:
logger = getLogger(state.get('envs')['LOGGER_NAME'])
logger.setLevel(state.get('envs')['LOGGER_LEVEL'])
handler = StreamHandler()
logger.addHandler(handler)
return logger
@app.command(name='greet:to', positionals=[('name', {'default': 'World!'})])
async def handle_greeting(name: str, logger: Logger = Depends(_get_logger)) -> int:
logger.info(f'Hello {name}')
return 0
@app.command(name='div', optionals=[('--a', {'type': float}), ('--b', {'type': float})])
async def handle_division(a: float, b: float, logger: Logger = Depends(_get_logger)) -> int:
try:
logger.info(f'Result {a} / {b} = {(a / b)}')
return 0
except BaseException as err:
logger.error(f'Error: {err}')
return 1
# python3 main.py <command> <positionals> <optionals>
if __name__ == '__main__':
run_app(app)
Requirements
- Python >= 3.10
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Metadata
Release files for aiocli 1.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiocli-1.12.0.tar.gz | 16.4 kB | Without provenance | Details for aiocli-1.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiocli-1.12.0-py3-none-any.whl | Python 3 | none | any | Details for aiocli-1.12.0-py3-none-any.whl |
Total release size: 30.6 kB
Release files / aiocli-1.12.0.tar.gz
| Download URL | aiocli-1.12.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ce369b19796ac3d5f4de6db847b36a1c8b5d1a44b70259f288f20b31415f2ff
|
|
BLAKE2b-256 checksum How to use checksums |
4c1f7f133fc37bd0d93531c2ba77b5cf143c75bcaa481701e6dd3d9a4b0c6084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / aiocli-1.12.0-py3-none-any.whl
| Download URL | aiocli-1.12.0-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
28962aa790ec62fcda6133b865017e9c4cdb3aecb79b333d9d9bc122508f9954
|
|
BLAKE2b-256 checksum How to use checksums |
09ee9d16990d2eff2f35191e31c3a2c8de5f59d47f3a76d6e405f1fd4ddf12e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for aiocli 1.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.