diff --git a/argenta/app/defaults.py b/argenta/app/defaults.py new file mode 100644 index 0000000..6d29a58 --- /dev/null +++ b/argenta/app/defaults.py @@ -0,0 +1,8 @@ +from dataclasses import dataclass + + +@dataclass +class PredeterminedMessages: + USAGE = '[b dim]Usage[/b dim]: [i] <[green]flags[/green]>[/i]' + HELP = '[b dim]Help[/b dim]: [i][/i] [b red]--help[/b red]' + diff --git a/argenta/app/entity.py b/argenta/app/entity.py index 4d39b11..94014e3 100644 --- a/argenta/app/entity.py +++ b/argenta/app/entity.py @@ -1,6 +1,7 @@ from typing import Callable from inspect import getfullargspec from rich.console import Console +from art import text2art import re from argenta.command.models import Command, InputCommand @@ -20,15 +21,17 @@ from argenta.app.registered_routers.entity import RegisteredRouters class App: def __init__(self, - prompt: str = 'Enter a command\n', - initial_message: str = '\nHello, I am Argenta\n', - farewell_message: str = '\nGoodBye\n', + prompt: str = '[italic dim bold]What do you want to do?\n', + initial_message: str = f'\n[bold red]{text2art('Argenta', font='tarty1')}\n\n', + farewell_message: str = f'[bold red]\n{text2art('\nSee you\n', font='chanky')}[/bold red]\n' + f'[red i]github.com/koloideal/Argenta[/red i] | ' + f'[red bold i]made by kolo[/red bold i]\n', exit_command: str = 'Q', exit_command_description: str = 'Exit command', system_points_title: str = 'System points:', ignore_exit_command_register: bool = True, - ignore_command_register: bool = False, - line_separate: str = '', + ignore_command_register: bool = True, + line_separate: str = f'\n[dim]{"--"*25}\n', command_group_description_separate: str = '', repeat_command_groups: bool = True, print_func: Callable[[str], None] = Console().print) -> None: @@ -45,12 +48,12 @@ class App: self._ignore_command_register = ignore_command_register self._repeat_command_groups_description = repeat_command_groups - self._description_message_pattern: str = '[{command}] *=*=* {description}' + self._description_message_pattern: str = '[bold red][{command}][/bold red] [blue dim]*=*=*[/blue dim] [bold yellow italic]{description}' self._registered_routers: RegisteredRouters = RegisteredRouters() - self._invalid_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'Incorrect flag syntax: "{raw_command}"') - self._repeated_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'Repeated input flags: "{raw_command}"') - self._empty_input_command_handler: Callable[[], None] = lambda: print_func('Empty input command') - self._unknown_command_handler: Callable[[InputCommand], None] = lambda command: print_func(f"Unknown command: {command.get_trigger()}") + self._invalid_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Incorrect flag syntax: {raw_command}') + self._repeated_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Repeated input flags: {raw_command}') + self._empty_input_command_handler: Callable[[], None] = lambda: print_func('[red bold]Empty input command') + self._unknown_command_handler: Callable[[InputCommand], None] = lambda command: print_func(f"[red bold]Unknown command: {command.get_trigger()}") self._exit_command_handler: Callable[[], None] = lambda: print_func(self._farewell_message) self._messages_on_startup = [] diff --git a/argenta/router/entity.py b/argenta/router/entity.py index a7fb6e4..fa36cd8 100644 --- a/argenta/router/entity.py +++ b/argenta/router/entity.py @@ -22,7 +22,6 @@ class Router: self._command_handlers: CommandHandlers = CommandHandlers() self._ignore_command_register: bool = False - self._not_valid_flag_handler: Callable[[Flag], None] = lambda flag: print(f"Undefined or incorrect input flag: {flag.get_string_entity()}{(' '+flag.get_value()) if flag.get_value() else ''}") diff --git a/mock/mock_app/main.py b/mock/mock_app/main.py index c1bd206..2407892 100644 --- a/mock/mock_app/main.py +++ b/mock/mock_app/main.py @@ -1,37 +1,18 @@ from mock.mock_app.handlers.routers import work_router, settings_router from art import text2art -from rich.console import Console from argenta.app import App +from argenta.app.defaults import PredeterminedMessages -app: App = App(prompt='[italic white bold]What do you want to do(enter number of action)?', - line_separate=f'\n{"[bold green]-[/bold green][bold red]-[/bold red]"*25}\n', - print_func=Console().print, - command_group_description_separate='ISIISISISIISISISISISISISISIISISI', - repeat_command_groups=True) +app: App = App() def main(): - ascii_name: str = text2art('WordMath', font='nancyj') - initial_greeting: str = f'[bold red]\n\n{ascii_name}' - - ascii_goodbye_message: str = text2art('GoodBye', font='small') - goodbye_message: str = f'[bold red]\n{ascii_goodbye_message}{' '*12}made by kolo\n' - app.include_routers(work_router, settings_router) - app.set_initial_message(initial_greeting) - app.set_farewell_message(goodbye_message) - - app.add_message_on_startup('[b dim]Usage[/b dim]: [i] <[green]flags[/green]>[/i]\n') - app.add_message_on_startup('[b dim]Help[/b dim]: [i][/i] [b red]--help[/b red]\n\n') - - app.set_invalid_input_flags_handler(lambda raw_command: print(f"Invalid input flags: {raw_command}")) - app.set_unknown_command_handler(lambda command: print(f"Unknown command: {command.get_trigger()}")) - app.set_repeated_input_flags_handler(lambda raw_command: print(f"Repeated input flags: {raw_command}")) - - app.set_description_message_pattern('[bold red][{command}][/bold red] [blue dim]*=*=*[/blue dim] [bold yellow italic]{description}') + app.add_message_on_startup(PredeterminedMessages.USAGE) + app.add_message_on_startup(PredeterminedMessages.HELP + '\n\n') app.start_polling() diff --git a/pyproject.toml b/pyproject.toml index a4600b9..c786bef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "argenta" -version = "0.4.5" +version = "0.4.6" description = "python library for creating custom shells" authors = [ {name = "kolo", email = "kolo.is.main@gmail.com"} @@ -8,7 +8,7 @@ authors = [ license = {text = "MIT"} readme = "README.md" requires-python = ">=3.11" -dependencies = [] # no dependencies +dependencies = ["rich (>=14.0.0,<15.0.0)", "art (>=6.4,<7.0)"] [tool.ruff] @@ -27,11 +27,5 @@ requires = ["poetry-core>=2.0.0,<3.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.group.dev.dependencies] -art = "^6.4" -rich = "^13.9.4" -numpy = "^2.2.2" -word2number = "^1.1" -numexpr = "^2.10.2" -requests = "^2.32.3" pyreadline3 = "^3.5.4"