mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
feat: impl docs (#4)
The entire public api is covered with documentation in two languages - Russian and English. the library now supports the latest three versions of python - 3.12, 3.13 and 3.14 minor design changes: now, when a Boolean flag is entered, its value is an empty string, not None. tests have been adapted to the supported versions of python, readmi has been redesigned in two languages, German is no longer available.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from argenta import Command, Response, Router
|
||||
from argenta.command import Flag, Flags
|
||||
from argenta.command.flag import InputFlag
|
||||
|
||||
router = Router(title="Contains Example")
|
||||
|
||||
|
||||
@router.command(
|
||||
Command(
|
||||
"check",
|
||||
description="Check flags",
|
||||
flags=Flags([Flag("verbose"), Flag("debug"), Flag("quiet")]),
|
||||
)
|
||||
)
|
||||
def check_handler(response: Response):
|
||||
input_flags = response.input_flags
|
||||
|
||||
# Check for specific flag presence
|
||||
verbose_flag = input_flags.get_flag_by_name("verbose")
|
||||
debug_flag = input_flags.get_flag_by_name("debug")
|
||||
|
||||
# Use 'in' operator for checking
|
||||
if verbose_flag and verbose_flag in input_flags:
|
||||
print("Verbose flag is present")
|
||||
|
||||
if debug_flag and debug_flag in input_flags:
|
||||
print("Debug flag is present")
|
||||
|
||||
# You can create a flag for checking (comparison is by name)
|
||||
test_flag = InputFlag(name="verbose", prefix="--", input_value="any", status=None)
|
||||
|
||||
if test_flag in input_flags:
|
||||
print("Verbose flag found using 'in' operator")
|
||||
Reference in New Issue
Block a user