Update documentation and code snippets

This commit is contained in:
2025-12-04 17:50:24 +03:00
parent eeb5a752ec
commit be083bb64d
+27 -58
View File
@@ -1,67 +1,45 @@
![preview](https://i.ibb.co/fTQXbXV/a-minimalist-logo-design-featuring-the-t-OL3-WIOEp-Q5izi-Oyd6-FHq-XQ-CCd1xei4-Q2-Sky-Z0-GPf-SWMA.jpg) ![preview](https://i.ibb.co/fTQXbXV/a-minimalist-logo-design-featuring-the-t-OL3-WIOEp-Q5izi-Oyd6-FHq-XQ-CCd1xei4-Q2-Sky-Z0-GPf-SWMA.jpg)
**Argenta** is a simple, yet elegant, CLI framework for building modular command-line applications. It provides a clean and intuitive way to create context-aware CLI tools with isolated command scopes. **Argenta** is a simple and elegant framework for building modular CLI applications. It provides a clean and intuitive way to create context-aware command-line tools with isolated command scopes.
Argenta is the **"Simplest"**, **"Most Modular"**, and **"Most Elegant"** way to build interactive CLI applications in Python. Argenta is the **"Simplest"**, **"Most Modular"**, and **"Most Elegant"** way to build interactive CLI applications in Python.
📖 **Read the full documentation:** [argenta-docs.vercel.app](https://argenta-docs.vercel.app)<br> 📖 **Read the full documentation:** [argenta.readthedocs.io](https://argenta.readthedocs.io/)<br>
🌍 **Other languages:** [RU](https://github.com/koloideal/Argenta/blob/main/README.ru.md) 🌍 **Other languages:** [RU](https://github.com/koloideal/Argenta/blob/main/README.ru.md)
--- ---
![preview](https://i.ibb.co/fzWcfgFq/2025-12-04-173045.png) ![preview](https://i.ibb.co/fzWcfgFq/2025-12-04-173045.png)
```python **Argenta** allows you to build interactive CLI applications incredibly easily. There's no need to manually parse complex command structures or manage state transitions — just use routers and commands!
>>> from argenta import Router, Command, Response
>>>
>>> router = Router()
>>>
>>> @router.command(Command("hello"))
... def handler(response: Response):
... print("Hello, world!")
>>>
>>> from argenta import App, Orchestrator
>>>
>>> app = App()
>>> app.include_router(router)
>>> orchestrator = Orchestrator()
>>> orchestrator.start_polling(app)
```
Argenta allows you to build interactive CLI applications extremely easily. There's no need to manually parse complex command structures or manage state transitions — just use routers and commands! ## ✨ Installing Argenta
## ✨ Installing Argenta and Supported Versions Argenta is available on ``PyPI``:
Argenta is available on PyPI:
```console ```console
$ python -m pip install argenta $ python -m pip install argenta
``` ```
or using Poetry: or using ``uv``:
```console ```console
$ poetry add argenta $ uv add argenta
``` ```
Argenta officially supports Python 3.7+. Argenta officially supports Python 3.12+.
## 🚀 Supported Features & Best Practices ## 🚀 Supported Features & Best Practices
Argenta is ready for the demands of building scalable, robust and maintainable CLI applications. Argenta is ready for the demands of building scalable, robust and maintainable CLI applications.
- Context-Aware Command Routing - **Interactive Sessions**: Unlike traditional CLI tools, ``Argenta`` creates cyclic sessions, allowing users to execute commands sequentially without restarting the application.
- Isolated Command Scopes - **Declarative Syntax**: Commands and their handlers are declared using simple decorators, making the code intuitive and allowing you to focus on "what" you want to do, not "how".
- Modular Router Architecture - **Native DI**: Thanks to integration with `dishka <https://dishka.readthedocs.io/en/stable/>`_, you can easily inject dependencies directly into command handlers, simplifying testing, avoiding mutable globals, and much more.
- Clean Decorator-Based API - **Automatic Validation and Parsing**: The library handles command-line flags and arguments processing, including parsing, validation, and type conversion.
- Response Object Pattern - **Flexible Configuration**: You can easily customize system messages, output formatting, create custom handlers for non-standard behavior, and more.
- Command Orchestration
- Interactive Polling Mode
- Fully Type-Annotated
- Easy to Test
- Extensible
Need something more? Create an issue, we listen. Need something more? Create an **issue**, we're open to suggestions.
## 📝 Why did we create this? ## 📝 Why did we create this?
@@ -77,9 +55,8 @@ Here's a simple example to get you started:
```python ```python
# routers.py # routers.py
from argenta.router import Router from argenta import Router, Response
from argenta.command import Command from argenta.command import Flag, Command
from argenta.response import Response
router = Router() router = Router()
@@ -88,18 +65,20 @@ def handler(response: Response):
"""A simple hello world command""" """A simple hello world command"""
print("Hello, world!") print("Hello, world!")
@router.command(Command("greet")) @router.command(Command("greet", flags=Flag('name')))
def greet_handler(response: Response): def greet_handler(response: Response):
"""Greet a user by name""" """Greet a user by name"""
name = response.args.get("name", "stranger") name_flag = response.input_flags.get_flag_by_name('name')
print(f"Hello, {name}!") if name_flag:
print(f"Hello, {name_flag.input_value}!")
else:
print("Hello, Stranger!")
``` ```
```python ```python
# main.py # main.py
from argenta.app import App from argenta import App, Orchestrator
from argenta.orchestrator import Orchestrator from .routers import router
from routers import router
app = App() app = App()
orchestrator = Orchestrator() orchestrator = Orchestrator()
@@ -115,22 +94,12 @@ if __name__ == '__main__':
main() main()
``` ```
That's it! You now have a fully functional interactive CLI application with modular command routing. That's it! You now have a fully functional interactive CLI application.
## 🔮 Features in Development
- Full autocomplete support on Linux
- Enhanced context switching
- Built-in command history
- Plugin system for extensions
## 📚 Documentation ## 📚 Documentation
Full documentation is available at [argenta-docs.vercel.app](https://argenta-docs.vercel.app) Full documentation is available at [argenta.readthedocs.io](https://argenta.readthedocs.io/)
--- ---
MIT 2025 kolo | made by [kolo](https://t.me/kolo_id) MIT 2025 kolo | made by [kolo](https://t.me/kolo_id)