mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
v0.2.1
This commit is contained in:
+23
-3
@@ -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,7 +52,13 @@ class App:
|
||||
|
||||
self.print_func(self.initial_greeting)
|
||||
|
||||
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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
+1
-1
@@ -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"}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user