mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
work on v0.3.0
This commit is contained in:
@@ -18,7 +18,7 @@ class Router:
|
|||||||
self._command_entities: list[dict[str, Callable[[], None] | Command]] = []
|
self._command_entities: list[dict[str, Callable[[], None] | Command]] = []
|
||||||
self.unknown_command_func: Callable[[str], None] | None = None
|
self.unknown_command_func: Callable[[str], None] | None = None
|
||||||
self._is_main_router: bool = False
|
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]:
|
def command(self, command: Command) -> Callable[[Any], Any]:
|
||||||
@@ -50,7 +50,7 @@ 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 self._ignore_command_register:
|
||||||
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():
|
||||||
is_valid = command_entity['command'].validate_input_flag(flag)
|
is_valid = command_entity['command'].validate_input_flag(flag)
|
||||||
@@ -77,9 +77,9 @@ class Router:
|
|||||||
|
|
||||||
def _validate_command(self, command: Command):
|
def _validate_command(self, command: Command):
|
||||||
command_name: str = command.get_string_entity()
|
command_name: str = command.get_string_entity()
|
||||||
if command in self.get_all_commands():
|
if command_name in self.get_all_commands():
|
||||||
raise RepeatedCommandException()
|
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()]:
|
if command_name.lower() in [x.lower() for x in self.get_all_commands()]:
|
||||||
raise RepeatedCommandException()
|
raise RepeatedCommandException()
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ class Router:
|
|||||||
|
|
||||||
|
|
||||||
def set_ignore_command_register(self, ignore_command_register: bool):
|
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]]:
|
def get_command_entities(self) -> list[dict[str, Callable[[], None] | Command]]:
|
||||||
@@ -116,7 +116,7 @@ class Router:
|
|||||||
return {
|
return {
|
||||||
'title': self.title,
|
'title': self.title,
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'ignore_command_register': self.ignore_command_register,
|
'ignore_command_register': self._ignore_command_register,
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'command_entities': self._command_entities,
|
'command_entities': self._command_entities,
|
||||||
'unknown_command_func': self.unknown_command_func,
|
'unknown_command_func': self.unknown_command_func,
|
||||||
|
|||||||
@@ -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):
|
def command_help(args: FlagsGroup):
|
||||||
|
print('Help command')
|
||||||
flags = args.get_flags()
|
flags = args.get_flags()
|
||||||
for flag in flags:
|
for flag in flags:
|
||||||
print(f'name: "{flag.get_string_entity()}", value: "{flag.get_value()}"')
|
print(f'name: "{flag.get_string_entity()}", value: "{flag.get_value()}"')
|
||||||
#help_command()
|
#help_command()
|
||||||
|
|
||||||
|
|
||||||
'''@work_router.command(command='1', description='Start Solving')
|
@work_router.command(Command(command='I', description='Start Solving', flags=flagi))
|
||||||
def command_start_solving():
|
def command_start_solving(args: FlagsGroup):
|
||||||
start_solving_command()
|
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():
|
def command_update():
|
||||||
upgrade_command()'''
|
print('uefi')
|
||||||
|
# upgrade_command()
|
||||||
|
|
||||||
|
|
||||||
@work_router.unknown_command
|
@work_router.unknown_command
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ def main():
|
|||||||
goodbye_message: str = f'[bold red]\n{ascii_goodbye_message}{' '*12}made by kolo\n'
|
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(work_router, is_main=True)
|
||||||
#app.include_router(settings_router)
|
app.include_router(settings_router)
|
||||||
|
|
||||||
app.set_initial_message(initial_greeting)
|
app.set_initial_message(initial_greeting)
|
||||||
app.set_farewell_message(goodbye_message)
|
app.set_farewell_message(goodbye_message)
|
||||||
|
|||||||
Reference in New Issue
Block a user