This commit is contained in:
2025-02-23 18:53:11 +03:00
parent f87f102ced
commit ef242a5732
2 changed files with 6 additions and 14 deletions
+3 -11
View File
@@ -1,4 +1,5 @@
from typing import Callable, Any from typing import Callable, Any
from inspect import getfullargspec
from ..command.entity import Command from ..command.entity import Command
from ..command.input_comand.entity import InputCommand from ..command.input_comand.entity import InputCommand
from ..command.input_comand.exceptions import InvalidInputFlagException from ..command.input_comand.exceptions import InvalidInputFlagException
@@ -50,16 +51,6 @@ class Router:
input_command_name: str = input_command.get_string_entity() input_command_name: str = input_command.get_string_entity()
for command_entity in self._command_entities: for command_entity in self._command_entities:
if input_command_name.lower() == command_entity['command'].get_string_entity().lower(): if input_command_name.lower() == command_entity['command'].get_string_entity().lower():
if self._ignore_command_register:
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']()
else:
if input_command_name == command_entity['command'].get_string_entity(): if input_command_name == command_entity['command'].get_string_entity():
if input_command.get_input_flags(): if input_command.get_input_flags():
for flag in input_command.get_input_flags(): for flag in input_command.get_input_flags():
@@ -68,7 +59,8 @@ class Router:
raise InvalidInputFlagException(flag) raise InvalidInputFlagException(flag)
return command_entity['handler_func'](input_command.get_input_flags()) return command_entity['handler_func'](input_command.get_input_flags())
else: else:
return command_entity['handler_func']() print(getfullargspec(command_entity['handler_func']))
return command_entity['handler_func'](None)
def get_unknown_command_func(self): def get_unknown_command_func(self):
+2 -2
View File
@@ -21,7 +21,7 @@ flagi = FlagsGroup(flags=[
@work_router.command(Command(command='0', description='Get Help', flags=flagi)) @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') print('Help command')
flags = args.get_flags() flags = args.get_flags()
for flag in 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)) @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...') print('Solving...')
flags = args.get_flags() flags = args.get_flags()
for flag in flags: for flag in flags: