From b4b7d5442c15932853b817d0f4bc225cc8f3e8fd Mon Sep 17 00:00:00 2001 From: kolo Date: Sun, 9 Feb 2025 22:47:53 +0300 Subject: [PATCH] v0.2.1 --- argenta/app/entity.py | 28 ++++++++++++++++++++++++---- pyproject.toml | 2 +- setup.py | 2 +- tests/mock_app/handlers/routers.py | 6 ++---- tests/mock_app/main.py | 3 ++- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/argenta/app/entity.py b/argenta/app/entity.py index d799986..77cc2c6 100644 --- a/argenta/app/entity.py +++ b/argenta/app/entity.py @@ -14,23 +14,29 @@ from .exceptions import (InvalidRouterInstanceException, class App: def __init__(self, prompt: str = 'Enter a command', - exit_command: str = 'q', - ignore_exit_command_register: bool = True, initial_greeting: str = '\nHello, I am Argenta\n', farewell_message: str = '\nGoodBye\n', + exit_command: str = 'Q', + exit_command_description: str = 'Exit command', + exit_command_title: str = 'System points:', + ignore_exit_command_register: bool = True, + ignore_command_register: bool = False, line_separate: str = '', command_group_description_separate: str = '', - ignore_command_register: bool = False, + repeat_command_groups: bool = True, print_func: Callable[[str], None] = print) -> None: self.prompt = prompt self.print_func = print_func self.exit_command = exit_command + self.exit_command_description = exit_command_description + self.exit_command_title = exit_command_title self.ignore_exit_command_register = ignore_exit_command_register self.farewell_message = farewell_message self.initial_greeting = initial_greeting self.line_separate = line_separate self.command_group_description_separate = command_group_description_separate self.ignore_command_register = ignore_command_register + self.repeat_command_groups = repeat_command_groups self._routers: list[Router] = [] self._registered_router_entities: list[dict[str, str | list[dict[str, Callable[[], None] | str]] | Router]] = [] @@ -46,8 +52,14 @@ class App: self.print_func(self.initial_greeting) - while True: + if not self.repeat_command_groups: self._print_command_group_description() + if self.repeat_command_groups: + self.print_func(self.prompt) + + while True: + if self.repeat_command_groups: + self._print_command_group_description() self.print_func(self.prompt) command: str = input() @@ -177,6 +189,14 @@ class App: ) self.print_func(self.command_group_description_separate) + self.print_func(self.exit_command_title) + self.print_func(self._description_message_pattern.format( + command=self.exit_command, + description=self.exit_command_description + ) + ) + self.print_func(self.command_group_description_separate) + def include_router(self, router: Router, is_main: True | False = False) -> None: if not isinstance(router, Router): diff --git a/pyproject.toml b/pyproject.toml index 05b8ef5..21f22ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "argenta" -version = "0.2.0" +version = "0.2.1" description = "python library for creating cli apps" authors = [ {name = "kolo",email = "kolo.is.main@gmail.com"} diff --git a/setup.py b/setup.py index e74c722..1d90347 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setup( name="argenta", - version="0.2.0", + version="0.2.1", author="kolo", author_email="kolo.is.main@gmail.com", description="Python library for creating CLI apps", diff --git a/tests/mock_app/handlers/routers.py b/tests/mock_app/handlers/routers.py index fb4f429..d927fbf 100644 --- a/tests/mock_app/handlers/routers.py +++ b/tests/mock_app/handlers/routers.py @@ -6,10 +6,8 @@ from ..handlers.handlers_implementation.solving_command import start_solving_com from ..handlers.handlers_implementation.upgrade_command import upgrade_command -work_router: Router = Router(name='Work points:', - ignore_command_register=False) -settings_router: Router = Router(name='Settings points:', - ignore_command_register=True) +work_router: Router = Router(title='Work points:') +settings_router: Router = Router(title='Settings points:') console = Console() diff --git a/tests/mock_app/main.py b/tests/mock_app/main.py index 4a235ab..26ab60e 100644 --- a/tests/mock_app/main.py +++ b/tests/mock_app/main.py @@ -7,7 +7,8 @@ from rich.console import Console app: App = App(prompt='[italic white bold]What do you want to do(enter number of action)?', line_separate='[bold green]\n---------------------------------------------\n', print_func=Console().print, - command_group_description_separate='') + command_group_description_separate='', + repeat_command_groups=False) def main():