This commit is contained in:
2025-04-06 18:57:30 +03:00
parent 1a2e9d1487
commit ab1d335f8e
7 changed files with 35 additions and 16 deletions
+2 -2
View File
@@ -102,7 +102,7 @@ App(prompt: str = 'What do you want to do?\n',
exit_command_description: str = 'Exit command',
system_points_title: str = 'System points:',
ignore_command_register: bool = True,
line_separate: str = '-----',
dividing_line: str = '-----',
repeat_command_groups: bool = True,
print_func: Callable[[str], None] = Console().print)
```
@@ -115,7 +115,7 @@ App(prompt: str = 'What do you want to do?\n',
- `exit_command_description` (`str`): Описание команды выхода.
- `system_points_title` (`str`): Заголовок перед списком системных команд.
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
- `line_separate` (`str`): Разделительная строка между командами.
- `dividing_line` (`str`): Разделительная строка между командами.
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
+15
View File
@@ -0,0 +1,15 @@
from collections.abc import Sized
def check(string: str):
if len(string) != 1:
raise ValueError
class BaseDividingLine:
def __init__(self, unit_part: check):
self.unit_part = unit_part
BaseDividingLine('sygu')
+6 -7
View File
@@ -29,7 +29,7 @@ class BaseApp:
exit_command_description: str = 'Exit command',
system_points_title: str = 'System points:',
ignore_command_register: bool = True,
line_separate: str = '-',
dividing_line: str = '-',
repeat_command_groups: bool = True,
print_func: Callable[[str], None] = Console().print) -> None:
self._prompt = prompt
@@ -37,7 +37,7 @@ class BaseApp:
self._exit_command = exit_command
self._exit_command_description = exit_command_description
self._system_points_title = system_points_title
self._line_separate = line_separate
self._dividing_line = dividing_line
self._ignore_command_register = ignore_command_register
self._repeat_command_groups_description = repeat_command_groups
@@ -132,14 +132,13 @@ class BaseApp:
def _print_framed_text(self, text: str):
max_length_line = max([len([char for char in line if char.isalnum()]) for line in text.split('\n')])
with open('test.txt', 'w') as file:
file.write(text)
clear_text = re.sub(r'\u001b\[[0-9;]*m', '', text)
max_length_line = max([len(line) for line in clear_text.split('\n')])
max_length_line = max_length_line if 10 <= max_length_line <= 80 else 80 if max_length_line > 80 else 10
self._print_func(self._make_line_separator(max_length_line, self._line_separate))
self._print_func(self._make_line_separator(max_length_line, self._dividing_line))
print(text.strip('\n'))
self._print_func(self._make_line_separator(max_length_line, self._line_separate))
self._print_func(self._make_line_separator(max_length_line, self._dividing_line))
+4 -2
View File
@@ -1,12 +1,14 @@
from contextlib import redirect_stdout
import io
import string
while True:
with redirect_stdout(io.StringIO()) as f:
a = input('rgsert')
a = input()
print(a)
res = f.getvalue()
res = ''.join([x for x in res if x in string.printable])
print('-'*len(res))
print(res.replace('\n', ''))
print(res.strip('\n'))
print('-'*len(res))
+7 -4
View File
@@ -1,7 +1,7 @@
from rich.console import Console
from argenta.command import Command
from argenta.command.flag import Flags, InputFlags
from argenta.command.flag import Flags, InputFlags, Flag
from argenta.command.flag.defaults import PredeterminedFlags
from argenta.router import Router
from .handlers_implementation.help_command import help_command
@@ -15,15 +15,18 @@ settings_router: Router = Router(title='Settings points:')
console = Console()
flag = Flag('test')
@work_router.command(Command(trigger='0', description='Get Help'))
@work_router.command(Command(trigger='0',
description='Get Help'))
def command_help():
help_command()
@work_router.command(Command(trigger='S', description='Start Solving', flags=Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT)))
@work_router.command(Command(trigger='S', description='Start Solving', flags=Flags(PredeterminedFlags.HOST, PredeterminedFlags.PORT, flag)))
def command_start_solving(args: InputFlags):
print(args.get_flags())
print(args.get_flag('test'))
@settings_router.command(Command(trigger='U', description='Update WordMath'))
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "argenta"
version = "0.4.7"
description = "python library for creating tui"
description = "Python library for creating TUI"
authors = [
{name = "kolo", email = "kolo.is.main@gmail.com"}
]