This commit is contained in:
2025-11-01 11:38:48 +03:00
parent 0598f6e7a5
commit e4a5c6d398
73 changed files with 53 additions and 50 deletions
+26
View File
@@ -0,0 +1,26 @@
from argenta import Command
from argenta.command import Flag, Flags
# Простая команда без флагов
hello_cmd = Command(
"hello",
description="Greet the user"
)
# Команда с описанием и псевдонимами
quit_cmd = Command(
"quit",
description="Exit the application",
aliases=["exit", "q"]
)
# Команда с флагами
deploy_cmd = Command(
"deploy",
description="Deploy application to server",
flags=Flags([
Flag("env", help="Environment name", possible_values=["dev", "prod"]),
Flag("force", help="Force deployment")
]),
aliases=["dep"]
)
+18
View File
@@ -0,0 +1,18 @@
from argenta import Router, Command, Response
router = Router(title="User Management")
@router.command(Command(
"create-user",
description="Create a new user account"
))
def handle_create_user(response):
print("Creating new user...")
@router.command(Command(
"delete-user",
description="Delete existing user account",
aliases=["remove-user", "rm-user"]
))
def handle_delete_user(response: Response):
print("Deleting user...")
+28
View File
@@ -0,0 +1,28 @@
from argenta import Router, Command, Response
from argenta.command import Flag, Flags
router = Router(title="Server Management")
@router.command(Command(
"start",
description="Start the server",
flags=Flags([
Flag("port", help="Server port", default="8080"),
Flag("host", help="Server host", default="localhost"),
Flag("debug", help="Enable debug mode")
]),
aliases=["run"]
))
def handle_start(response: Response):
input_flags = response.input_flags
port_flag = input_flags.get_flag_by_name("port")
host_flag = input_flags.get_flag_by_name("host")
debug_flag = input_flags.get_flag_by_name("debug")
host = host_flag.input_value if host_flag else "localhost"
port = port_flag.input_value if port_flag else "8080"
debug = debug_flag and debug_flag.input_value
print(f"Starting server on {host}:{port}")
if debug:
print("Debug mode: ON")
+11
View File
@@ -0,0 +1,11 @@
from argenta.command import InputCommand
# Парсинг команды без флагов
cmd1 = InputCommand.parse("hello")
print(cmd1.trigger) # "hello"
print(len(cmd1.input_flags)) # 0
# Парсинг команды с флагами
cmd2 = InputCommand.parse("deploy --env prod --force")
print(cmd2.trigger) # "deploy"
print(len(cmd2.input_flags)) # 2