mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
work
This commit is contained in:
@@ -102,7 +102,7 @@ App(prompt: str = 'What do you want to do?\n',
|
|||||||
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,
|
||||||
line_separate: str = '-----',
|
dividing_line: str = '-----',
|
||||||
repeat_command_groups: bool = True,
|
repeat_command_groups: bool = True,
|
||||||
print_func: Callable[[str], None] = Console().print)
|
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`): Описание команды выхода.
|
- `exit_command_description` (`str`): Описание команды выхода.
|
||||||
- `system_points_title` (`str`): Заголовок перед списком системных команд.
|
- `system_points_title` (`str`): Заголовок перед списком системных команд.
|
||||||
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
|
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
|
||||||
- `line_separate` (`str`): Разделительная строка между командами.
|
- `dividing_line` (`str`): Разделительная строка между командами.
|
||||||
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
|
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
|
||||||
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
|
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
|
||||||
|
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class BaseApp:
|
|||||||
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,
|
||||||
line_separate: str = '-',
|
dividing_line: str = '-',
|
||||||
repeat_command_groups: bool = True,
|
repeat_command_groups: bool = True,
|
||||||
print_func: Callable[[str], None] = Console().print) -> None:
|
print_func: Callable[[str], None] = Console().print) -> None:
|
||||||
self._prompt = prompt
|
self._prompt = prompt
|
||||||
@@ -37,7 +37,7 @@ class BaseApp:
|
|||||||
self._exit_command = exit_command
|
self._exit_command = exit_command
|
||||||
self._exit_command_description = exit_command_description
|
self._exit_command_description = exit_command_description
|
||||||
self._system_points_title = system_points_title
|
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._ignore_command_register = ignore_command_register
|
||||||
self._repeat_command_groups_description = repeat_command_groups
|
self._repeat_command_groups_description = repeat_command_groups
|
||||||
|
|
||||||
@@ -132,14 +132,13 @@ class BaseApp:
|
|||||||
|
|
||||||
|
|
||||||
def _print_framed_text(self, text: str):
|
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')])
|
clear_text = re.sub(r'\u001b\[[0-9;]*m', '', text)
|
||||||
with open('test.txt', 'w') as file:
|
max_length_line = max([len(line) for line in clear_text.split('\n')])
|
||||||
file.write(text)
|
|
||||||
max_length_line = max_length_line if 10 <= max_length_line <= 80 else 80 if max_length_line > 80 else 10
|
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'))
|
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
@@ -1,12 +1,14 @@
|
|||||||
from contextlib import redirect_stdout
|
from contextlib import redirect_stdout
|
||||||
import io
|
import io
|
||||||
|
import string
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
with redirect_stdout(io.StringIO()) as f:
|
with redirect_stdout(io.StringIO()) as f:
|
||||||
a = input('rgsert')
|
a = input()
|
||||||
print(a)
|
print(a)
|
||||||
res = f.getvalue()
|
res = f.getvalue()
|
||||||
|
res = ''.join([x for x in res if x in string.printable])
|
||||||
print('-'*len(res))
|
print('-'*len(res))
|
||||||
print(res.replace('\n', ''))
|
print(res.strip('\n'))
|
||||||
print('-'*len(res))
|
print('-'*len(res))
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
from argenta.command import Command
|
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.command.flag.defaults import PredeterminedFlags
|
||||||
from argenta.router import Router
|
from argenta.router import Router
|
||||||
from .handlers_implementation.help_command import help_command
|
from .handlers_implementation.help_command import help_command
|
||||||
@@ -15,15 +15,18 @@ settings_router: Router = Router(title='Settings points:')
|
|||||||
|
|
||||||
console = Console()
|
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():
|
def command_help():
|
||||||
help_command()
|
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):
|
def command_start_solving(args: InputFlags):
|
||||||
print(args.get_flags())
|
print(args.get_flag('test'))
|
||||||
|
|
||||||
|
|
||||||
@settings_router.command(Command(trigger='U', description='Update WordMath'))
|
@settings_router.command(Command(trigger='U', description='Update WordMath'))
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "argenta"
|
name = "argenta"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
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