aiocli-1.8.0
توضیحات
Simple and lightweight async console runner.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aiocli-1.8.0 |
| نام | aiocli |
| نسخه کتابخانه | 1.8.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | ['ticdenis <denisnavarroalcaide@outlook.es>'] |
| نویسنده | - |
| ایمیل نویسنده | ticdenis <denisnavarroalcaide@outlook.es>, yasti4 <adria_4_@hotmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/aiocli/ |
| مجوز | MIT |
# Async cli client/commander framework
[](https://badge.fury.io/py/aiocli)
[](https://pepy.tech/project/aiocli)
[](https://github.com/aiopy/python-aiocli/actions/workflows/ci.yml)
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](https://pypi.org/project/aiocli/) to install aiocli.
```bash
pip install aiocli
```
## Documentation
- Visit [aiocli docs](https://aiopy.github.io/python-aiocli/).
## Usage
```python
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.7
## 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
[MIT](https://github.com/aiopy/python-aiocli/blob/master/LICENSE)
نیازمندی
| مقدار | نام |
|---|---|
| ==0.9.0 | build |
| ==65.6.0 | setuptools |
| ==4.0.1 | twine |
| ==0.38.4 | wheel |
| ==2.20.0 | pre-commit |
| ==2.0.1 | tomli |
| ==0.10.8.1 | types-toml |
| ==1.4.2 | mkdocs |
| ==8.5.10 | mkdocs-material |
| ==22.10.0 | black |
| ==5.10.1 | isort |
| ==1.7.4 | bandit |
| ==0.7.3 | liccheck |
| ==0.991 | mypy |
| ==2.15.6 | pylint |
| ==5.9.4 | psutil |
| ==7.2.0 | pytest |
| ==0.20.2 | pytest-asyncio |
| ==4.0.0 | pytest-cov |
| ==3.0.2 | pytest-xdist |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl aiocli-1.8.0:
pip install aiocli-1.8.0.whl
نصب پکیج tar.gz aiocli-1.8.0:
pip install aiocli-1.8.0.tar.gz