mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
docs
This commit is contained in:
@@ -2,25 +2,20 @@ from argenta import Command
|
||||
from argenta.command import Flag, Flags
|
||||
|
||||
# Простая команда без флагов
|
||||
hello_cmd = Command(
|
||||
"hello",
|
||||
description="Greet the user"
|
||||
)
|
||||
hello_cmd = Command("hello", description="Greet the user")
|
||||
|
||||
# Команда с описанием и псевдонимами
|
||||
quit_cmd = Command(
|
||||
"quit",
|
||||
description="Exit the application",
|
||||
aliases=["exit", "q"]
|
||||
)
|
||||
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"]
|
||||
)
|
||||
flags=Flags(
|
||||
[
|
||||
Flag("env", help="Environment name", possible_values=["dev", "prod"]),
|
||||
Flag("force", help="Force deployment"),
|
||||
]
|
||||
),
|
||||
aliases=["dep"],
|
||||
)
|
||||
|
||||
@@ -2,17 +2,18 @@ from argenta import Command, Response, Router
|
||||
|
||||
router = Router(title="User Management")
|
||||
|
||||
@router.command(Command(
|
||||
"create-user",
|
||||
description="Create a new user account"
|
||||
))
|
||||
|
||||
@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"]
|
||||
))
|
||||
|
||||
@router.command(
|
||||
Command(
|
||||
"delete-user",
|
||||
description="Delete existing user account",
|
||||
aliases=["remove-user", "rm-user"],
|
||||
)
|
||||
)
|
||||
def handle_delete_user(response: Response):
|
||||
print("Deleting user...")
|
||||
print("Deleting user...")
|
||||
|
||||
@@ -3,26 +3,31 @@ 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"]
|
||||
))
|
||||
|
||||
@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")
|
||||
print("Debug mode: ON")
|
||||
|
||||
@@ -8,4 +8,4 @@ print(len(cmd1.input_flags)) # 0
|
||||
# Парсинг команды с флагами
|
||||
cmd2 = InputCommand.parse("deploy --env prod --force")
|
||||
print(cmd2.trigger) # "deploy"
|
||||
print(len(cmd2.input_flags)) # 2
|
||||
print(len(cmd2.input_flags)) # 2
|
||||
|
||||
Reference in New Issue
Block a user