From a6db733204c0f36400f12aa3652594f4ecb9cd81 Mon Sep 17 00:00:00 2001 From: kolo Date: Sun, 13 Apr 2025 13:13:03 +0300 Subject: [PATCH] some fix --- argenta/app/models.py | 32 +++++++++++++++---------------- mock/mock_app/handlers/routers.py | 4 +++- pyproject.toml | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/argenta/app/models.py b/argenta/app/models.py index 3662fe6..8830cf8 100644 --- a/argenta/app/models.py +++ b/argenta/app/models.py @@ -105,6 +105,15 @@ class AppPrinters(AppInit): self._print_func(self._dividing_line.get_full_line(max_length_line)) + def _print_framed_text(self, text: str): + if isinstance(self._dividing_line, StaticDividingLine): + self._print_func(self._dividing_line.get_full_line()) + self._print_func(text) + self._print_func(self._dividing_line.get_full_line()) + elif isinstance(self._dividing_line, DynamicDividingLine): + self._print_framed_text_with_dynamic_line(text) + + class AppNonStandardHandlers(AppPrinters): def _is_exit_command(self, command: InputCommand): if command.get_trigger().lower() == self._exit_command.get_trigger().lower(): @@ -218,15 +227,10 @@ class App(AppSetters, AppNonStandardHandlers, AppSetups): try: input_command: InputCommand = InputCommand.parse(raw_command=raw_command) except BaseInputCommandException as error: - if isinstance(self._dividing_line, StaticDividingLine): - self._print_func(self._dividing_line.get_full_line()) + with redirect_stdout(io.StringIO()) as f: self._error_handler(error, raw_command) - self._print_func(self._dividing_line.get_full_line()) - elif isinstance(self._dividing_line, DynamicDividingLine): - with redirect_stdout(io.StringIO()) as f: - self._error_handler(error, raw_command) - res: str = f.getvalue() - self._print_framed_text_with_dynamic_line(res) + res: str = f.getvalue() + self._print_framed_text(res) continue if self._is_exit_command(input_command): @@ -236,17 +240,11 @@ class App(AppSetters, AppNonStandardHandlers, AppSetups): if self._is_unknown_command(input_command): continue - if isinstance(self._dividing_line, StaticDividingLine): - self._print_func(self._dividing_line.get_full_line()) + with redirect_stdout(io.StringIO()) as f: for registered_router in self._registered_routers: registered_router.input_command_handler(input_command) - self._print_func(self._dividing_line.get_full_line()) - elif isinstance(self._dividing_line, DynamicDividingLine): - with redirect_stdout(io.StringIO()) as f: - for registered_router in self._registered_routers: - registered_router.input_command_handler(input_command) - res: str = f.getvalue() - self._print_framed_text_with_dynamic_line(res) + res: str = f.getvalue() + self._print_framed_text(res) if not self._repeat_command_groups_description: self._print_func(self._prompt) diff --git a/mock/mock_app/handlers/routers.py b/mock/mock_app/handlers/routers.py index f3e040f..ea5f6c3 100644 --- a/mock/mock_app/handlers/routers.py +++ b/mock/mock_app/handlers/routers.py @@ -19,7 +19,9 @@ def command_help(): help_command() -@work_router.command(Command('start', 'Start Solving', Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT), aliases=['starting'])) +@work_router.command(Command('start', 'Start Solving', + flags=Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT), + aliases=['starting'])) def command_start_solving(args: InputFlags): print(args.get_flag('host')) diff --git a/pyproject.toml b/pyproject.toml index 2ff6c68..09c727b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "argenta" -version = "0.5.0-beta2" +version = "0.5.0" description = "Python library for creating TUI" authors = [ {name = "kolo", email = "kolo.is.main@gmail.com"}