mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
new tests
This commit is contained in:
@@ -176,9 +176,9 @@ class App(BaseApp)
|
||||
#### \_\_init\_\_
|
||||
|
||||
```python
|
||||
def __init__(prompt: str = '[italic dim bold]What do you want to do?\n',
|
||||
initial_message: str = '\nArgenta\n',
|
||||
farewell_message: str = '\nSee you\n',
|
||||
def __init__(prompt: str = 'What do you want to do?',
|
||||
initial_message: str = 'Argenta',
|
||||
farewell_message: str = 'See you',
|
||||
exit_command: Command = Command('Q', 'Exit command'),
|
||||
system_router_title: str | None = 'System points:',
|
||||
ignore_command_register: bool = True,
|
||||
@@ -218,8 +218,7 @@ Configures and manages all aspects of the behavior and presentation of the user
|
||||
#### set\_description\_message\_pattern
|
||||
|
||||
```python
|
||||
def set_description_message_pattern(
|
||||
pattern: Callable[[str, str], str]) -> None
|
||||
def set_description_message_pattern(pattern: Callable[[str, str], str]) -> None
|
||||
```
|
||||
|
||||
Public. Sets the output pattern of the available commands
|
||||
|
||||
@@ -9,14 +9,14 @@ work_router: Router = Router(title='Work points:')
|
||||
console = Console()
|
||||
|
||||
|
||||
@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help']))
|
||||
'''@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help']))
|
||||
def command_help():
|
||||
pass
|
||||
|
||||
|
||||
@work_router.command(Command('run', 'Run All'))
|
||||
def command_start_solving():
|
||||
pass
|
||||
pass'''
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class NoRegisteredHandlersException(Exception):
|
||||
"""
|
||||
The router has no registered handlers
|
||||
"""
|
||||
def __init__(self, router_name) -> None:
|
||||
self.router_name = router_name
|
||||
def __str__(self):
|
||||
return f"No Registered Handlers Found For '{self.router_name}'"
|
||||
@@ -15,7 +15,6 @@ from argenta.command.exceptions import (UnprocessedInputFlagException,
|
||||
RepeatedInputFlagsException,
|
||||
EmptyInputCommandException,
|
||||
BaseInputCommandException)
|
||||
from argenta.app.exceptions import NoRegisteredHandlersException
|
||||
from argenta.app.registered_routers.entity import RegisteredRouters
|
||||
|
||||
|
||||
@@ -184,11 +183,6 @@ class BaseApp:
|
||||
else:
|
||||
if input_command_trigger in self._all_registered_triggers_in_default_case:
|
||||
return False
|
||||
|
||||
with redirect_stdout(io.StringIO()) as f:
|
||||
self._unknown_command_handler(command)
|
||||
res: str = f.getvalue()
|
||||
self._print_framed_text(res)
|
||||
return True
|
||||
|
||||
|
||||
@@ -208,16 +202,6 @@ class BaseApp:
|
||||
self._empty_input_command_handler()
|
||||
|
||||
|
||||
def _validate_included_routers(self) -> None:
|
||||
"""
|
||||
Private. Validates included routers
|
||||
:return: None
|
||||
"""
|
||||
for router in self._registered_routers:
|
||||
if not router.get_command_handlers():
|
||||
raise NoRegisteredHandlersException(router.get_name())
|
||||
|
||||
|
||||
def _setup_system_router(self) -> None:
|
||||
"""
|
||||
Private. Sets up system router
|
||||
@@ -259,7 +243,6 @@ class BaseApp:
|
||||
"""
|
||||
self._setup_default_view()
|
||||
self._setup_system_router()
|
||||
self._validate_included_routers()
|
||||
|
||||
for router_entity in self._registered_routers:
|
||||
self._all_registered_triggers_in_default_case.extend(router_entity.get_triggers())
|
||||
@@ -351,6 +334,10 @@ class App(BaseApp):
|
||||
return
|
||||
|
||||
if self._is_unknown_command(input_command):
|
||||
with redirect_stdout(io.StringIO()) as f:
|
||||
self._unknown_command_handler(input_command)
|
||||
res: str = f.getvalue()
|
||||
self._print_framed_text(res)
|
||||
continue
|
||||
|
||||
with redirect_stdout(io.StringIO()) as f:
|
||||
|
||||
@@ -49,14 +49,14 @@ class CommandHandlers:
|
||||
"""
|
||||
self.command_handlers = command_handlers if command_handlers else []
|
||||
|
||||
def get_command_handlers(self) -> list[CommandHandler]:
|
||||
def get_handlers(self) -> list[CommandHandler]:
|
||||
"""
|
||||
Private. Returns the list of CommandHandlers
|
||||
:return: the list of CommandHandlers as list[CommandHandler]
|
||||
"""
|
||||
return self.command_handlers
|
||||
|
||||
def add_command_handler(self, command_handler: CommandHandler) -> None:
|
||||
def add_handler(self, command_handler: CommandHandler) -> None:
|
||||
"""
|
||||
Private. Adds a CommandHandler to the list of CommandHandlers
|
||||
:param command_handler: CommandHandler to be added
|
||||
@@ -64,7 +64,7 @@ class CommandHandlers:
|
||||
"""
|
||||
self.command_handlers.append(command_handler)
|
||||
|
||||
def add_command_handlers(self, *command_handlers: CommandHandler) -> None:
|
||||
def add_handlers(self, *command_handlers: CommandHandler) -> None:
|
||||
"""
|
||||
Private. Extend a many CommandHandler to the list of CommandHandlers
|
||||
:param command_handlers: many CommandHandler to be added
|
||||
|
||||
@@ -35,7 +35,7 @@ class Router:
|
||||
|
||||
def command_decorator(func):
|
||||
Router._validate_func_args(command, func)
|
||||
self._command_handlers.add_command_handler(CommandHandler(func, command))
|
||||
self._command_handlers.add_handler(CommandHandler(func, command))
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user