mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
fix many bugs
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
__all__ = ["App"]
|
||||
|
||||
from .models import App
|
||||
from argenta.app.models import App
|
||||
|
||||
@@ -109,7 +109,7 @@ class AppPrinters(AppInit):
|
||||
self._print_func(self._dividing_line.get_full_line(max_length_line))
|
||||
|
||||
|
||||
class AppNonStandardHandlers(AppInit, AppPrinters):
|
||||
class AppNonStandardHandlers(AppPrinters):
|
||||
def _is_exit_command(self, command: InputCommand):
|
||||
if command.get_trigger().lower() == self._exit_command.lower():
|
||||
if self._ignore_command_register:
|
||||
@@ -163,7 +163,7 @@ class AppValidators(AppInit):
|
||||
raise NoRegisteredHandlersException(router.get_name())
|
||||
|
||||
|
||||
class AppSetups(AppInit):
|
||||
class AppSetups(AppValidators, AppPrinters):
|
||||
def _setup_system_router(self):
|
||||
system_router.set_title(self._system_points_title)
|
||||
|
||||
@@ -182,12 +182,7 @@ class AppSetups(AppInit):
|
||||
f'[bold red]\n{text2art(f'\n{self._farewell_message}\n', font='chanky')}[/bold red]\n'
|
||||
f'[red i]github.com/koloideal/Argenta[/red i] | [red bold i]made by kolo[/red bold i]\n')
|
||||
|
||||
|
||||
|
||||
class App(AppInit, AppSetters,
|
||||
AppNonStandardHandlers,
|
||||
AppValidators, AppSetups):
|
||||
def start_polling(self) -> None:
|
||||
def _pre_cycle_setup(self):
|
||||
self._setup_default_view()
|
||||
self._setup_system_router()
|
||||
self._validate_number_of_routers()
|
||||
@@ -201,6 +196,10 @@ class App(AppInit, AppSetters,
|
||||
if not self._repeat_command_groups_description:
|
||||
self._print_command_group_description()
|
||||
|
||||
|
||||
class App(AppSetters, AppNonStandardHandlers, AppSetups):
|
||||
def start_polling(self) -> None:
|
||||
self._pre_cycle_setup()
|
||||
while True:
|
||||
if self._repeat_command_groups_description:
|
||||
self._print_command_group_description()
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
__all__ = ["Command"]
|
||||
|
||||
from .models import Command
|
||||
from argenta.command.models import Command
|
||||
@@ -1,4 +1,4 @@
|
||||
__all__ = ('InputFlags', 'InputFlag', 'Flag', 'Flags')
|
||||
|
||||
|
||||
from .models import InputFlags, InputFlag, Flags, Flag
|
||||
from argenta.command.flag.models import InputFlags, InputFlag, Flags, Flag
|
||||
|
||||
@@ -5,9 +5,7 @@ from argenta.app.defaults import PredeterminedMessages
|
||||
from argenta.app.dividing_line import DynamicDividingLine
|
||||
|
||||
|
||||
app: App = App(dividing_line=DynamicDividingLine(),
|
||||
initial_message='WordMath',
|
||||
farewell_message='shiiiit')
|
||||
app: App = App(dividing_line=DynamicDividingLine())
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "argenta"
|
||||
version = "0.4.9"
|
||||
version = "0.4.10"
|
||||
description = "Python library for creating TUI"
|
||||
authors = [
|
||||
{name = "kolo", email = "kolo.is.main@gmail.com"}
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.unknown_command_handler = lambda command: print(f'Unknown command: {command.get_trigger()}')
|
||||
app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
@@ -43,7 +43,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App(ignore_command_register=False)
|
||||
app.include_router(router)
|
||||
app.unknown_command_handler = lambda command: print(f'Unknown command: {command.get_trigger()}')
|
||||
app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
@@ -117,12 +117,12 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.unknown_command_handler = lambda command: print(f'Unknown command: {command.get_trigger()}')
|
||||
app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
|
||||
self.assertRegex(output, re.compile(r'\ntest command\n(.|\n)*\nUnknown command: some\n'))
|
||||
self.assertRegex(output, re.compile(r'\ntest command\n(.|\n)*\nUnknown command: some'))
|
||||
|
||||
|
||||
@patch("builtins.input", side_effect=["test", "some", "more", "q"])
|
||||
@@ -140,7 +140,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.unknown_command_handler = lambda command: print(f'Unknown command: {command.get_trigger()}')
|
||||
app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
@@ -159,7 +159,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.invalid_input_flags_handler = lambda command: print(f'Incorrect flag syntax: "{command}"')
|
||||
app.set_invalid_input_flags_handler(lambda command: print(f'Incorrect flag syntax: "{command}"'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
@@ -178,7 +178,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.empty_input_command_handler = lambda: print('Empty input command')
|
||||
app.set_empty_command_handler(lambda: print('Empty input command'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
@@ -197,9 +197,9 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
app.repeated_input_flags_handler = lambda command: print(f'Repeated input flags: "{command}"')
|
||||
app.set_repeated_input_flags_handler(lambda command: print(f'Repeated input flags: "{command}"'))
|
||||
app.start_polling()
|
||||
|
||||
output = mock_stdout.getvalue()
|
||||
|
||||
self.assertIn("\nRepeated input flags: \"test --port 22 --port 33\"", output)
|
||||
self.assertIn("\nRepeated input flags: \"test --port 22 --port 33\"\n", output)
|
||||
|
||||
Reference in New Issue
Block a user