mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
Update documentation
This commit is contained in:
@@ -8,11 +8,8 @@ from argenta.response.status import ResponseStatus
|
||||
|
||||
router = Router("Calculator")
|
||||
|
||||
operations = {
|
||||
'mul': operator.mul,
|
||||
'sub': operator.sub,
|
||||
'add': operator.add
|
||||
}
|
||||
operations = {"mul": operator.mul, "sub": operator.sub, "add": operator.add}
|
||||
|
||||
|
||||
@router.command(
|
||||
Command(
|
||||
@@ -22,7 +19,9 @@ operations = {
|
||||
[
|
||||
Flag("a", possible_values=re.compile(r"^\d{,5}$")), # First number
|
||||
Flag("b", possible_values=re.compile(r"^\d{,5}$")), # Second number
|
||||
Flag("operation", possible_values=["add", "sub", "mul"]), # Operation: add, sub, mul
|
||||
Flag(
|
||||
"operation", possible_values=["add", "sub", "mul"]
|
||||
), # Operation: add, sub, mul
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ app = App(
|
||||
prompt=">> ",
|
||||
initial_message="Simple App",
|
||||
farewell_message="Goodbye!",
|
||||
repeat_command_groups_printing=False
|
||||
repeat_command_groups_printing=False,
|
||||
)
|
||||
orchestrator = Orchestrator()
|
||||
|
||||
@@ -15,11 +15,7 @@ main_router = Router(title="Main commands")
|
||||
|
||||
|
||||
# 3. Define command and its handler
|
||||
@main_router.command(Command(
|
||||
"hello",
|
||||
description="Prints greeting message",
|
||||
flags=Flag("name")
|
||||
))
|
||||
@main_router.command(Command("hello", description="Prints greeting message", flags=Flag("name")))
|
||||
def hello_handler(response: Response):
|
||||
"""This handler will be called for 'hello' command."""
|
||||
name = response.input_flags.get_flag_by_name("name")
|
||||
|
||||
@@ -10,25 +10,29 @@ from .repository import Priority, Task, TaskRepository
|
||||
router = Router(title="Task Manager")
|
||||
|
||||
|
||||
@router.command(Command(
|
||||
@router.command(
|
||||
Command(
|
||||
"add-task",
|
||||
description="Add a new task",
|
||||
flags=Flags([
|
||||
flags=Flags(
|
||||
[
|
||||
Flag("description"),
|
||||
Flag("priority", possible_values=["low", "medium", "high"]),
|
||||
]),
|
||||
))
|
||||
]
|
||||
),
|
||||
)
|
||||
)
|
||||
def add_task(response: Response, repo: FromDishka[TaskRepository]):
|
||||
description_flag = response.input_flags.get_flag_by_name("description")
|
||||
|
||||
|
||||
if not description_flag or not description_flag.status == ValidationStatus.VALID:
|
||||
print("Error: --description flag is required.")
|
||||
return
|
||||
|
||||
|
||||
task_description = description_flag.input_value or ""
|
||||
|
||||
priority_flag = response.input_flags.get_flag_by_name("priority")
|
||||
|
||||
|
||||
if priority_flag and priority_flag.status == ValidationStatus.VALID:
|
||||
priority_value = priority_flag.input_value
|
||||
else:
|
||||
@@ -38,14 +42,14 @@ def add_task(response: Response, repo: FromDishka[TaskRepository]):
|
||||
|
||||
task = Task(description=task_description, priority=priority)
|
||||
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()
|
||||
|
||||
|
||||
if not tasks:
|
||||
print("No tasks found.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user