mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
docs
This commit is contained in:
@@ -6,10 +6,11 @@ from argenta import App, Orchestrator
|
||||
app: App = App()
|
||||
orchestrator: Orchestrator = Orchestrator()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app.include_router(router)
|
||||
orchestrator.start_polling(app)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -3,7 +3,7 @@ from argenta import Command, Response, Router
|
||||
|
||||
router = Router(title="Quickstart Example")
|
||||
|
||||
|
||||
@router.command(Command("hello", description="Say hello"))
|
||||
def handler(response: Response):
|
||||
print("Hello, world!")
|
||||
|
||||
@@ -9,14 +9,17 @@ from .repository import Priority, Task, TaskRepository
|
||||
|
||||
router = Router(title="Task Manager")
|
||||
|
||||
|
||||
@router.command(
|
||||
Command(
|
||||
"add-task",
|
||||
description="Add a new task",
|
||||
flags=Flags([
|
||||
Flag("description"),
|
||||
Flag("priority", possible_values=["low", "medium", "high"]),
|
||||
])
|
||||
flags=Flags(
|
||||
[
|
||||
Flag("description"),
|
||||
Flag("priority", possible_values=["low", "medium", "high"]),
|
||||
]
|
||||
),
|
||||
)
|
||||
)
|
||||
def add_task(response: Response, repo: FromDishka[TaskRepository]):
|
||||
@@ -40,6 +43,7 @@ def add_task(response: Response, repo: FromDishka[TaskRepository]):
|
||||
repo.add_task(task)
|
||||
print(f"Added task: '{task.description}' with priority '{task.priority}'")
|
||||
|
||||
|
||||
@router.command(Command("list-tasks", description="List all tasks"))
|
||||
def list_tasks(response: Response, repo: FromDishka[TaskRepository]):
|
||||
tasks = repo.get_all_tasks()
|
||||
|
||||
@@ -3,11 +3,13 @@ from typing import Literal
|
||||
|
||||
Priority = Literal["low", "medium", "high"]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Task:
|
||||
description: str
|
||||
priority: Priority = "medium"
|
||||
|
||||
|
||||
class TaskRepository:
|
||||
def __init__(self):
|
||||
self._tasks: list[Task] = []
|
||||
|
||||
Reference in New Issue
Block a user