mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
some fix
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Описание
|
## Описание
|
||||||
**Argenta** — Python library for creating custom shells
|
**Argenta** — Python library for creating TUI
|
||||||
|
|
||||||

|

|
||||||
Пример внешнего вида TUI, написанного с помощью Argenta
|
Пример внешнего вида TUI, написанного с помощью Argenta
|
||||||
@@ -104,6 +104,7 @@ App(prompt: str = 'What do you want to do?\n',
|
|||||||
ignore_command_register: bool = True,
|
ignore_command_register: bool = True,
|
||||||
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
||||||
repeat_command_groups: bool = True,
|
repeat_command_groups: bool = True,
|
||||||
|
full_override_system_messages: bool = False
|
||||||
print_func: Callable[[str], None] = Console().print)
|
print_func: Callable[[str], None] = Console().print)
|
||||||
```
|
```
|
||||||
**Аргументы:**
|
**Аргументы:**
|
||||||
@@ -117,6 +118,7 @@ App(prompt: str = 'What do you want to do?\n',
|
|||||||
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
|
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
|
||||||
- `dividing_line` (`StaticDividingLine | DynamicDividingLine`): Разделительная строка.
|
- `dividing_line` (`StaticDividingLine | DynamicDividingLine`): Разделительная строка.
|
||||||
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
|
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
|
||||||
|
- `full_override_system_messages` (`bool`): Переопределить ли дефолтное оформление сообщений ([подробнее см.](#override_defaults))
|
||||||
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
|
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -224,6 +226,11 @@ App(prompt: str = 'What do you want to do?\n',
|
|||||||
- Наиболее частые сообщение при запуске предопределены и доступны для быстрого
|
- Наиболее частые сообщение при запуске предопределены и доступны для быстрого
|
||||||
использования: `argenta.app.defaults.PredeterminedMessages`
|
использования: `argenta.app.defaults.PredeterminedMessages`
|
||||||
|
|
||||||
|
<a name="override_defaults"></a>
|
||||||
|
- Если `override_system_messages`=`False`, то при переопределении таких атрибутов как `initial_message` и
|
||||||
|
`farawell_message` будет использовано дефолтное оформление текста, в виде красного ascii арта, при значении
|
||||||
|
`override_system_messages`=`True` системные сообщения будут отображены в точности какими были переданы
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
__all__ = ["StaticDividingLine", "DynamicDividingLine"]
|
||||||
|
|
||||||
|
|
||||||
|
from argenta.app.dividing_line.models import StaticDividingLine, DynamicDividingLine
|
||||||
|
|||||||
+10
-12
@@ -24,14 +24,15 @@ from argenta.app.registered_routers.entity import RegisteredRouters
|
|||||||
class BaseApp:
|
class BaseApp:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
prompt: str = '[italic dim bold]What do you want to do?\n',
|
prompt: str = '[italic dim bold]What do you want to do?\n',
|
||||||
initial_message: str = 'Argenta',
|
initial_message: str = '\nArgenta\n',
|
||||||
farewell_message: str = 'See you',
|
farewell_message: str = '\nSee you\n',
|
||||||
exit_command: str = 'Q',
|
exit_command: str = 'Q',
|
||||||
exit_command_description: str = 'Exit command',
|
exit_command_description: str = 'Exit command',
|
||||||
system_points_title: str = 'System points:',
|
system_points_title: str = 'System points:',
|
||||||
ignore_command_register: bool = True,
|
ignore_command_register: bool = True,
|
||||||
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
||||||
repeat_command_groups: bool = True,
|
repeat_command_groups: bool = True,
|
||||||
|
full_override_system_messages: bool = False,
|
||||||
print_func: Callable[[str], None] = Console().print) -> None:
|
print_func: Callable[[str], None] = Console().print) -> None:
|
||||||
self._prompt = prompt
|
self._prompt = prompt
|
||||||
self._print_func = print_func
|
self._print_func = print_func
|
||||||
@@ -41,6 +42,7 @@ class BaseApp:
|
|||||||
self._dividing_line = dividing_line
|
self._dividing_line = dividing_line
|
||||||
self._ignore_command_register = ignore_command_register
|
self._ignore_command_register = ignore_command_register
|
||||||
self._repeat_command_groups_description = repeat_command_groups
|
self._repeat_command_groups_description = repeat_command_groups
|
||||||
|
self._full_override_system_messages = full_override_system_messages
|
||||||
|
|
||||||
self.farewell_message = farewell_message
|
self.farewell_message = farewell_message
|
||||||
self.initial_message = initial_message
|
self.initial_message = initial_message
|
||||||
@@ -55,18 +57,14 @@ class BaseApp:
|
|||||||
self.unknown_command_handler: Callable[[InputCommand], None] = lambda command: print_func(f"[red bold]Unknown command: {command.get_trigger()}")
|
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.exit_command_handler: Callable[[], None] = lambda: print_func(self.farewell_message)
|
||||||
|
|
||||||
self._setup_default_view(is_initial_message_default=initial_message == 'Argenta',
|
self._setup_default_view()
|
||||||
is_farewell_message_default=farewell_message == 'See you')
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_default_view(self, is_initial_message_default: bool,
|
def _setup_default_view(self):
|
||||||
is_farewell_message_default: bool):
|
if not self._full_override_system_messages:
|
||||||
if is_initial_message_default:
|
self.initial_message = f'\n[bold red]{text2art(self.initial_message, font='tarty1')}\n\n'
|
||||||
self.initial_message = f'\n[bold red]{text2art('Argenta', font='tarty1')}\n\n'
|
self.farewell_message = (f'[bold red]\n{text2art(f'\n{self.farewell_message}\n', font='chanky')}[/bold red]\n'
|
||||||
if is_farewell_message_default:
|
f'[red i]github.com/koloideal/Argenta[/red i] | [red bold i]made by kolo[/red bold i]\n')
|
||||||
self.farewell_message = (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')
|
|
||||||
|
|
||||||
|
|
||||||
def _validate_number_of_routers(self) -> None:
|
def _validate_number_of_routers(self) -> None:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__all__ = ["Router"]
|
__all__ = ["Router"]
|
||||||
|
|
||||||
|
|
||||||
from .entity import Router
|
from argenta.router.entity import Router
|
||||||
@@ -18,18 +18,17 @@ console = Console()
|
|||||||
flag = Flag('test')
|
flag = Flag('test')
|
||||||
|
|
||||||
|
|
||||||
@work_router.command(Command(trigger='0',
|
@work_router.command(Command('0', 'Get Help'))
|
||||||
description='Get Help'))
|
|
||||||
def command_help():
|
def command_help():
|
||||||
help_command()
|
help_command()
|
||||||
|
|
||||||
|
|
||||||
@work_router.command(Command(trigger='S', description='Start Solving', flags=Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT, flag)))
|
@work_router.command(Command('S', 'Start Solving', Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT, flag)))
|
||||||
def command_start_solving(args: InputFlags):
|
def command_start_solving(args: InputFlags):
|
||||||
print(args.get_flag('test'))
|
print(args.get_flag('test'))
|
||||||
|
|
||||||
|
|
||||||
@settings_router.command(Command(trigger='U', description='Update WordMath'))
|
@settings_router.command(Command('U', 'Update WordMath'))
|
||||||
def command_update():
|
def command_update():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ from mock.mock_app.handlers.routers import work_router, settings_router
|
|||||||
|
|
||||||
from argenta.app import App
|
from argenta.app import App
|
||||||
from argenta.app.defaults import PredeterminedMessages
|
from argenta.app.defaults import PredeterminedMessages
|
||||||
from argenta.app.dividing_line.models import StaticDividingLine, DynamicDividingLine
|
from argenta.app.dividing_line import DynamicDividingLine
|
||||||
|
|
||||||
|
|
||||||
app: App = App(dividing_line=DynamicDividingLine())
|
app: App = App(dividing_line=DynamicDividingLine(),
|
||||||
|
initial_message='WordMath',
|
||||||
|
farewell_message='shiiiit')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "argenta"
|
name = "argenta"
|
||||||
version = "0.4.8"
|
version = "0.4.9"
|
||||||
description = "Python library for creating TUI"
|
description = "Python library for creating TUI"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "kolo", email = "kolo.is.main@gmail.com"}
|
{name = "kolo", email = "kolo.is.main@gmail.com"}
|
||||||
|
|||||||
Reference in New Issue
Block a user