This commit is contained in:
2025-03-12 00:51:11 +03:00
parent d30515c1a2
commit 0f4f48555e
3 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -6,6 +6,7 @@ from .exceptions import (UnprocessedInputFlagException,
from typing import Generic, TypeVar, cast, Literal
CommandType = TypeVar('CommandType')
@@ -15,8 +16,7 @@ class Command(Generic[CommandType]):
flags: Flag | FlagsGroup = None):
self._trigger = trigger
self._description = f'description for "{self._trigger}" command' if not description else description
self._registered_flags: FlagsGroup | None = flags if isinstance(flags, FlagsGroup) else FlagsGroup([flags]) if isinstance(flags, Flag) else flags
self._registered_flags: FlagsGroup | None = flags if isinstance(flags, FlagsGroup) else FlagsGroup(flags) if isinstance(flags, Flag) else flags
self._input_flags: FlagsGroup | None = None
@@ -56,7 +56,7 @@ class Command(Generic[CommandType]):
return self._input_flags
@staticmethod
def parse_input_command(raw_command: str) -> 'Command[CommandType]':
def parse_input_command(raw_command: str) -> CommandType:
if not raw_command:
raise EmptyInputCommandException()
list_of_tokens = raw_command.split()
+1 -1
View File
@@ -28,8 +28,8 @@ class Flag:
self._flag_value = value
def validate_input_flag_value(self, input_flag_value: str | None):
if self.possible_flag_values is False:
if input_flag_value is None:
if self.possible_flag_values is False:
return True
else:
return False
+2 -2
View File
@@ -10,7 +10,7 @@ from .handlers_implementation.help_command import help_command
work_router: Router = Router(title='Work nts:')
work_router.set_invalid_input_flag_handler(lambda flag: print(f'Invalid input flag: "{flag.get_string_entity()} {flag.get_value()}"'))
work_router.set_invalid_input_flag_handler(lambda flag: print(f'Invalid input flag: "{flag.get_string_entity()} {flag.get_value() if flag.get_value() else ''}"'))
settings_router: Router = Router(title='Settings points:')
@@ -23,7 +23,7 @@ def command_help():
help_command()
@work_router.command(Command(trigger='j', description='Start Solving', flags=FlagsGroup(host_flag, port_flag)))
@work_router.command(Command(trigger='P', description='Start Solving', flags=FlagsGroup(host_flag, port_flag)))
def command_start_solving(args: dict):
print('Solving...')
pprint(args)