From ef242a5732f7d3944ffe824358da3154c777914d Mon Sep 17 00:00:00 2001 From: kolo Date: Sun, 23 Feb 2025 18:53:11 +0300 Subject: [PATCH] fix --- argenta/router/entity.py | 16 ++++------------ tests/mock_app/handlers/routers.py | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/argenta/router/entity.py b/argenta/router/entity.py index 86a7891..a2b4ede 100644 --- a/argenta/router/entity.py +++ b/argenta/router/entity.py @@ -1,4 +1,5 @@ from typing import Callable, Any +from inspect import getfullargspec from ..command.entity import Command from ..command.input_comand.entity import InputCommand from ..command.input_comand.exceptions import InvalidInputFlagException @@ -50,7 +51,7 @@ class Router: input_command_name: str = input_command.get_string_entity() for command_entity in self._command_entities: if input_command_name.lower() == command_entity['command'].get_string_entity().lower(): - if self._ignore_command_register: + if input_command_name == command_entity['command'].get_string_entity(): if input_command.get_input_flags(): for flag in input_command.get_input_flags(): is_valid = command_entity['command'].validate_input_flag(flag) @@ -58,17 +59,8 @@ class Router: raise InvalidInputFlagException(flag) return command_entity['handler_func'](input_command.get_input_flags()) else: - return command_entity['handler_func']() - else: - if input_command_name == command_entity['command'].get_string_entity(): - if input_command.get_input_flags(): - for flag in input_command.get_input_flags(): - is_valid = command_entity['command'].validate_input_flag(flag) - if not is_valid: - raise InvalidInputFlagException(flag) - return command_entity['handler_func'](input_command.get_input_flags()) - else: - return command_entity['handler_func']() + print(getfullargspec(command_entity['handler_func'])) + return command_entity['handler_func'](None) def get_unknown_command_func(self): diff --git a/tests/mock_app/handlers/routers.py b/tests/mock_app/handlers/routers.py index e1bf9aa..522152d 100644 --- a/tests/mock_app/handlers/routers.py +++ b/tests/mock_app/handlers/routers.py @@ -21,7 +21,7 @@ flagi = FlagsGroup(flags=[ @work_router.command(Command(command='0', description='Get Help', flags=flagi)) -def command_help(args: FlagsGroup): +def command_help(args: FlagsGroup | None): print('Help command') flags = args.get_flags() for flag in flags: @@ -30,7 +30,7 @@ def command_help(args: FlagsGroup): @work_router.command(Command(command='P', description='Start Solving', flags=flagi)) -def command_start_solving(args: FlagsGroup): +def command_start_solving(args: FlagsGroup | None): print('Solving...') flags = args.get_flags() for flag in flags: