Update documentation and code snippets

This commit is contained in:
2025-12-02 10:51:44 +03:00
parent 2a96dfcabe
commit 19906c1b1b
28 changed files with 85 additions and 531 deletions
+7 -6
View File
@@ -1,5 +1,6 @@
from argenta import Command, Response, Router
from argenta.command import Flag, Flags
from argenta.command.flag import ValidationStatus
from argenta.response import ResponseStatus
router = Router(title="Flags Example")
@@ -9,14 +10,15 @@ router = Router(title="Flags Example")
Command(
"process",
description="Process with flags",
flags=Flags([Flag("format", possible_values=["json", "xml"]), Flag("verbose")]),
flags=Flags([
Flag("format", possible_values=["json", "xml"]),
Flag("verbose")
]),
)
)
def process_handler(response: Response):
# Проверяем статус валидации флагов
print(f"Status: {response.status.value}")
print(f"Status: {response.status}")
# Работаем с флагами
format_flag = response.input_flags.get_flag_by_name("format")
verbose_flag = response.input_flags.get_flag_by_name("verbose")
@@ -27,11 +29,10 @@ def process_handler(response: Response):
if verbose_flag:
print("Verbose mode enabled")
# Проверяем валидность флагов
if response.status == ResponseStatus.ALL_FLAGS_VALID:
print("All flags are valid, proceeding...")
elif response.status == ResponseStatus.INVALID_VALUE_FLAGS:
print("Warning: Some flags have invalid values")
for flag in response.input_flags:
if flag.status and flag.status.name == "INVALID":
if flag.status == ValidationStatus.INVALID:
print(f" Invalid flag: {flag.string_entity} = {flag.input_value}")