pretty gifff

This commit is contained in:
2026-01-15 02:02:50 +03:00
parent cd3dd10d11
commit 0f8b1c05fc
12 changed files with 36 additions and 51 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ Argenta is the **"Simplest"**, **"Most Modular"**, and **"Most Elegant"** way to
--- ---
![preview](https://i.ibb.co/fzWcfgFq/2025-12-04-173045.png) ![preview](https://vhs.charm.sh/vhs-2hvLCEgclmwZPJZt1vLGKi.gif)
**Argenta** allows you to build interactive CLI applications incredibly easily. There's no need to manually parse complex command structures or manage state transitions — just use routers and commands! **Argenta** allows you to build interactive CLI applications incredibly easily. There's no need to manually parse complex command structures or manage state transitions — just use routers and commands!
+1 -1
View File
@@ -9,7 +9,7 @@ Argenta — это **"Самый простой"**, **"Самый модульн
--- ---
![preview](https://i.ibb.co/fzWcfgFq/2025-12-04-173045.png) ![preview](https://vhs.charm.sh/vhs-2hvLCEgclmwZPJZt1vLGKi.gif)
**Argenta** позволяет создавать интерактивные CLI-приложения невероятно легко. Не нужно вручную парсить сложные структуры команд или управлять переходами состояний — просто используйте роутеры и команды! **Argenta** позволяет создавать интерактивные CLI-приложения невероятно легко. Не нужно вручную парсить сложные структуры команд или управлять переходами состояний — просто используйте роутеры и команды!
+1
View File
@@ -0,0 +1 @@
from .benchmarks.pre_cycle_setup import *
+10 -1
View File
@@ -1,10 +1,19 @@
from metrics.utils import attempts_to_average
from .registry import Benchmarks, Benchmark from .registry import Benchmarks, Benchmark
def main(): def main():
all_benchmarks: list[Benchmark] = Benchmarks.get_benchmarks() all_benchmarks: list[Benchmark] = Benchmarks.get_benchmarks()
for benchmark in all_benchmarks: pass for benchmark in all_benchmarks:
bench_attempts: list[float] = []
for _ in range(benchmark.iterations):
bench_attempts.append(benchmark.run())
print(f'Name: {benchmark.name}\n'
f'Description: {benchmark.description}\n'
f'Iterations: {benchmark.iterations}\n'
f'Average time per iteration: {attempts_to_average(bench_attempts, benchmark.iterations)} ms\n')
if __name__ == '__main__': if __name__ == '__main__':
+8
View File
@@ -1,3 +1,11 @@
__all__ = [
"benchmark_no_aliases",
"benchmark_many_aliases",
"benchmark_few_aliases",
"benchmark_extreme_aliases",
"benchmark_very_many_aliases"
]
from argenta import App from argenta import App
from argenta.router import Router from argenta.router import Router
from argenta.command.models import Command from argenta.command.models import Command
+1 -1
View File
@@ -23,7 +23,7 @@ class Benchmark:
self.description = description self.description = description
self.iterations = iterations self.iterations = iterations
def __call__(self) -> float: def run(self) -> float:
return self.func() return self.func()
@override @override
+6 -5
View File
@@ -1,22 +1,23 @@
__all__ = [ __all__ = [
"get_time_of_pre_cycle_setup", "get_time_of_pre_cycle_setup",
"attempts_to_average"
] ]
import io import io
from contextlib import redirect_stdout from contextlib import redirect_stdout
import time import time
from decimal import Decimal, ROUND_HALF_UP
from argenta import App from argenta import App
def get_time_of_pre_cycle_setup(app: App) -> float: def get_time_of_pre_cycle_setup(app: App) -> float:
"""
Public. Return time of pre cycle setup
:param app: app instance for testing time of pre cycle setup
:return: time of pre cycle setup as float
"""
start = time.monotonic() start = time.monotonic()
with redirect_stdout(io.StringIO()): with redirect_stdout(io.StringIO()):
app._pre_cycle_setup() # pyright: ignore[reportPrivateUsage] app._pre_cycle_setup() # pyright: ignore[reportPrivateUsage]
end = time.monotonic() end = time.monotonic()
return end - start return end - start
def attempts_to_average(bench_attempts: list[float], iterations: int) -> Decimal:
return Decimal(sum(bench_attempts) / iterations).quantize(Decimal("0.00001"), rounding=ROUND_HALF_UP)
View File
-32
View File
@@ -1,32 +0,0 @@
from argenta.app import App
from argenta.command import Command
from argenta.metrics import get_time_of_pre_cycle_setup
from argenta.response import Response
from argenta.router import Router
def commands_with_two_aliases(num_of_commands: int):
router = Router()
for i in range(num_of_commands):
@router.command(Command(f'cmd{i}', aliases=[f'cdr{i}', f'prt{i}']))
def handler(response: Response): # pyright: ignore[reportUnusedFunction, reportUnusedParameter]
pass
app = App()
app.include_router(router)
return get_time_of_pre_cycle_setup(app)
def commands_with_one_aliases(num_of_commands: int):
router = Router()
for i in range(num_of_commands):
@router.command(Command(f'cmd{i}', aliases=[f'cdr{i}']))
def handler(response: Response): # pyright: ignore[reportUnusedFunction, reportUnusedParameter]
pass
app = App()
app.include_router(router)
return get_time_of_pre_cycle_setup(app)
+2 -1
View File
@@ -1,9 +1,10 @@
# main.py # main.py
from argenta import App, Orchestrator from argenta import App, Orchestrator
from argenta.app import DynamicDividingLine
from .routers import router from .routers import router
app: App = App() app: App = App(prompt='>>> ', dividing_line=DynamicDividingLine('~'))
orchestrator: Orchestrator = Orchestrator() orchestrator: Orchestrator = Orchestrator()
def main() -> None: def main() -> None:
+3 -4
View File
@@ -339,9 +339,6 @@ class BaseApp:
self._autocompleter.initial_setup(self.registered_routers.get_triggers()) self._autocompleter.initial_setup(self.registered_routers.get_triggers())
if not self._override_system_messages:
self._setup_default_view()
self._print_func(self._initial_message) self._print_func(self._initial_message)
for message in self._messages_on_startup: for message in self._messages_on_startup:
@@ -382,7 +379,7 @@ DEFAULT_DIVIDING_LINE: StaticDividingLine = StaticDividingLine()
DEFAULT_PRINT_FUNC: Printer = Console().print DEFAULT_PRINT_FUNC: Printer = Console().print
DEFAULT_AUTOCOMPLETER: AutoCompleter = AutoCompleter() DEFAULT_AUTOCOMPLETER: AutoCompleter = AutoCompleter()
DEFAULT_EXIT_COMMAND: Command = Command("Q", description="Exit command") DEFAULT_EXIT_COMMAND: Command = Command("q", description="Exit command")
class App(BaseApp): class App(BaseApp):
@@ -427,6 +424,8 @@ class App(BaseApp):
autocompleter=autocompleter, autocompleter=autocompleter,
print_func=print_func, print_func=print_func,
) )
if not self._override_system_messages:
self._setup_default_view()
def run_polling(self) -> None: def run_polling(self) -> None:
""" """
-2
View File
@@ -361,8 +361,6 @@ def test_set_exit_command_handler_stores_handler() -> None:
def test_setup_default_view_formats_prompt() -> None: def test_setup_default_view_formats_prompt() -> None:
app = App(prompt='>>') app = App(prompt='>>')
app._setup_default_view()
assert app._prompt == '[italic dim bold]>>' assert app._prompt == '[italic dim bold]>>'