work on v0.3.0

This commit is contained in:
2025-02-22 12:14:25 +03:00
parent 76c18ddbff
commit eac5358ead
3 changed files with 19 additions and 13 deletions
+6 -6
View File
@@ -18,7 +18,7 @@ class Router:
self._command_entities: list[dict[str, Callable[[], None] | Command]] = []
self.unknown_command_func: Callable[[str], None] | None = None
self._is_main_router: bool = False
self.ignore_command_register: bool = False
self._ignore_command_register: bool = False
def command(self, command: Command) -> Callable[[Any], Any]:
@@ -50,7 +50,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 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)
@@ -77,9 +77,9 @@ class Router:
def _validate_command(self, command: Command):
command_name: str = command.get_string_entity()
if command in self.get_all_commands():
if command_name in self.get_all_commands():
raise RepeatedCommandException()
if self.ignore_command_register:
if self._ignore_command_register:
if command_name.lower() in [x.lower() for x in self.get_all_commands()]:
raise RepeatedCommandException()
@@ -97,7 +97,7 @@ class Router:
def set_ignore_command_register(self, ignore_command_register: bool):
self.ignore_command_register = ignore_command_register
self._ignore_command_register = ignore_command_register
def get_command_entities(self) -> list[dict[str, Callable[[], None] | Command]]:
@@ -116,7 +116,7 @@ class Router:
return {
'title': self.title,
'name': self.name,
'ignore_command_register': self.ignore_command_register,
'ignore_command_register': self._ignore_command_register,
'attributes': {
'command_entities': self._command_entities,
'unknown_command_func': self.unknown_command_func,
+12 -6
View File
@@ -20,22 +20,28 @@ flagi =FlagsGroup(flags=[
])
@work_router.command(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):
print('Help command')
flags = args.get_flags()
for flag in flags:
print(f'name: "{flag.get_string_entity()}", value: "{flag.get_value()}"')
#help_command()
'''@work_router.command(command='1', description='Start Solving')
def command_start_solving():
start_solving_command()
@work_router.command(Command(command='I', description='Start Solving', flags=flagi))
def command_start_solving(args: FlagsGroup):
print('Solving...')
flags = args.get_flags()
for flag in flags:
print(f'name: "{flag.get_string_entity()}", value: "{flag.get_value()}"')
#start_solving_command()
@settings_router.command(command='U', description='Update WordMath')
@settings_router.command(Command(command='i', description='Update WordMath'))
def command_update():
upgrade_command()'''
print('uefi')
# upgrade_command()
@work_router.unknown_command
+1 -1
View File
@@ -19,7 +19,7 @@ def main():
goodbye_message: str = f'[bold red]\n{ascii_goodbye_message}{' '*12}made by kolo\n'
app.include_router(work_router, is_main=True)
#app.include_router(settings_router)
app.include_router(settings_router)
app.set_initial_message(initial_greeting)
app.set_farewell_message(goodbye_message)