mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
work on Response model
This commit is contained in:
@@ -3,6 +3,7 @@ from rich.console import Console
|
||||
from argenta.command import Command
|
||||
from argenta.command.flag.defaults import PredefinedFlags
|
||||
from argenta.command.flag.models import Flag
|
||||
from argenta.command.flags.models import Flags
|
||||
from argenta.response import Response
|
||||
from argenta.router import Router
|
||||
|
||||
@@ -12,7 +13,8 @@ work_router: Router = Router(title='Work points:')
|
||||
console = Console()
|
||||
|
||||
|
||||
@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help'], flags=PredefinedFlags.PORT))
|
||||
@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help'], flags=Flags(PredefinedFlags.PORT,
|
||||
PredefinedFlags.HOST)))
|
||||
def command_help(response: Response):
|
||||
print(response.status)
|
||||
print(response.undefined_flags.get_flags())
|
||||
@@ -23,6 +25,7 @@ def command_help(response: Response):
|
||||
@work_router.command(Command('run', 'Run All'))
|
||||
def command_start_solving(response: Response):
|
||||
print(response.status)
|
||||
print('srsfbd')
|
||||
print(response.undefined_flags.get_flags())
|
||||
print(response.valid_flags.get_flags())
|
||||
print(response.invalid_value_flags.get_flags())
|
||||
|
||||
@@ -7,6 +7,13 @@ class Response:
|
||||
valid_flags: ValidInputFlags = ValidInputFlags(),
|
||||
undefined_flags: UndefinedInputFlags = UndefinedInputFlags(),
|
||||
invalid_value_flags: InvalidValueInputFlags = InvalidValueInputFlags()):
|
||||
"""
|
||||
Public. The entity of the user input sent to the handler
|
||||
:param status: the status of the response
|
||||
:param valid_flags: valid input flags
|
||||
:param undefined_flags: undefined input flags
|
||||
:param invalid_value_flags: input flags with invalid values
|
||||
"""
|
||||
self.status = status
|
||||
self.valid_flags = valid_flags
|
||||
self.undefined_flags = undefined_flags
|
||||
|
||||
@@ -34,7 +34,7 @@ class Router:
|
||||
self._validate_command(command)
|
||||
|
||||
def command_decorator(func):
|
||||
Router._validate_func_args(command, func)
|
||||
Router._validate_func_args(func)
|
||||
self._command_handlers.add_handler(CommandHandler(func, command))
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
@@ -134,10 +134,9 @@ class Router:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def _validate_func_args(command: Command, func: Callable) -> None:
|
||||
def _validate_func_args(func: Callable) -> None:
|
||||
"""
|
||||
Private. Validates the arguments of the handler
|
||||
:param command: registered command in handler
|
||||
:param func: entity of the handler func
|
||||
:return: None if func is valid else raise exception
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user