mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
Update documentation and code snippets
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from argenta import App, Command, Orchestrator, Router, Response
|
||||
from argenta.command import Flag
|
||||
|
||||
# 1. Создание экземпляра приложения и оркестратора
|
||||
# 1. Create app and orchestrator instances
|
||||
app = App(
|
||||
prompt=">> ",
|
||||
initial_message="Simple App",
|
||||
@@ -9,28 +9,28 @@ app = App(
|
||||
)
|
||||
orchestrator = Orchestrator()
|
||||
|
||||
# 2. Создание роутера для группировки команд
|
||||
main_router = Router(title="Основные команды")
|
||||
# 2. Create router for grouping commands
|
||||
main_router = Router(title="Main commands")
|
||||
|
||||
|
||||
# 3. Определение команды и её обработчика
|
||||
# 3. Define command and its handler
|
||||
@main_router.command(
|
||||
Command(
|
||||
"hello", description="Печатает приветственное сообщение", flags=Flag("name")
|
||||
"hello", description="Prints greeting message", flags=Flag("name")
|
||||
)
|
||||
)
|
||||
def hello_handler(response: Response):
|
||||
"""Этот обработчик будет вызван для команды 'hello'."""
|
||||
"""This handler will be called for 'hello' command."""
|
||||
name = response.input_flags.get_flag_by_name("name")
|
||||
if name:
|
||||
print(f"Привет, {name.input_value}!")
|
||||
print(f"Hello, {name.input_value}!")
|
||||
else:
|
||||
print("Привет, мир!")
|
||||
print("Hello, world!")
|
||||
|
||||
|
||||
# 4. Подключение роутера к приложению
|
||||
# 4. Include router to application
|
||||
app.include_router(main_router)
|
||||
|
||||
# 5. Запуск приложения
|
||||
# 5. Start application
|
||||
if __name__ == "__main__":
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
@@ -3,16 +3,16 @@ from argenta import App, Orchestrator
|
||||
from .handlers import router
|
||||
from .provider import TaskProvider
|
||||
|
||||
# 1. Создаем экземпляр приложения и оркестратора
|
||||
# 1. Create app and orchestrator instances
|
||||
app = App(
|
||||
initial_message="Task Manager",
|
||||
prompt="Enter a command: ",
|
||||
)
|
||||
orchestrator = Orchestrator(custom_providers=[TaskProvider()])
|
||||
|
||||
# 2. Подключаем роутер с нашими командами
|
||||
# 2. Include router with our commands
|
||||
app.include_router(router)
|
||||
|
||||
# 3. Запускаем поллинг через оркестратор
|
||||
# 3. Start polling via orchestrator
|
||||
if __name__ == "__main__":
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
Reference in New Issue
Block a user