mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e768c1bd2c | |||
| 408450ec12 |
@@ -9,14 +9,14 @@ work_router: Router = Router(title='Work points:')
|
|||||||
console = Console()
|
console = Console()
|
||||||
|
|
||||||
|
|
||||||
'''@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help']))
|
@work_router.command(Command('get', 'Get Help', aliases=['help', 'Get_help']))
|
||||||
def command_help():
|
def command_help():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@work_router.command(Command('run', 'Run All'))
|
@work_router.command(Command('run', 'Run All'))
|
||||||
def command_start_solving():
|
def command_start_solving():
|
||||||
pass'''
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "argenta"
|
name = "argenta"
|
||||||
version = "1.0.0-alpha2"
|
version = "1.0.0-alpha4"
|
||||||
description = "Python library for creating TUI"
|
description = "Python library for creating TUI"
|
||||||
authors = [{ name = "kolo", email = "kolo.is.main@gmail.com" }]
|
authors = [{ name = "kolo", email = "kolo.is.main@gmail.com" }]
|
||||||
requires-python = ">=3.11, <4.0"
|
requires-python = ">=3.11, <4.0"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class AutoCompleter:
|
|||||||
self.autocomplete_button = autocomplete_button
|
self.autocomplete_button = autocomplete_button
|
||||||
self.matches: list[str] = []
|
self.matches: list[str] = []
|
||||||
|
|
||||||
def complete(self, text, state) -> str | None:
|
def _complete(self, text, state) -> str | None:
|
||||||
"""
|
"""
|
||||||
Private. Auto-completion function
|
Private. Auto-completion function
|
||||||
:param text: part of the command being entered
|
:param text: part of the command being entered
|
||||||
@@ -51,7 +51,7 @@ class AutoCompleter:
|
|||||||
for line in all_commands:
|
for line in all_commands:
|
||||||
readline.add_history(line)
|
readline.add_history(line)
|
||||||
|
|
||||||
readline.set_completer(self.complete)
|
readline.set_completer(self._complete)
|
||||||
readline.set_completer_delims(readline.get_completer_delims().replace(' ', ''))
|
readline.set_completer_delims(readline.get_completer_delims().replace(' ', ''))
|
||||||
readline.parse_and_bind(f'{self.autocomplete_button}: complete')
|
readline.parse_and_bind(f'{self.autocomplete_button}: complete')
|
||||||
|
|
||||||
|
|||||||
+18
-18
@@ -61,58 +61,58 @@ class BaseApp:
|
|||||||
self._exit_command_handler: Callable[[], None] = lambda: print_func(self._farewell_message)
|
self._exit_command_handler: Callable[[], None] = lambda: print_func(self._farewell_message)
|
||||||
|
|
||||||
|
|
||||||
def set_description_message_pattern(self, pattern: Callable[[str, str], str]) -> None:
|
def set_description_message_pattern(self, _: Callable[[str, str], str]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the output pattern of the available commands
|
Public. Sets the output pattern of the available commands
|
||||||
:param pattern: output pattern of the available commands
|
:param _: output pattern of the available commands
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._description_message_gen: Callable[[str, str], str] = pattern
|
self._description_message_gen: Callable[[str, str], str] = _
|
||||||
|
|
||||||
|
|
||||||
def set_invalid_input_flags_handler(self, handler: Callable[[str], None]) -> None:
|
def set_invalid_input_flags_handler(self, _: Callable[[str], None]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the handler for incorrect flags when entering a command
|
Public. Sets the handler for incorrect flags when entering a command
|
||||||
:param handler: handler for incorrect flags when entering a command
|
:param _: handler for incorrect flags when entering a command
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._invalid_input_flags_handler = handler
|
self._invalid_input_flags_handler = _
|
||||||
|
|
||||||
|
|
||||||
def set_repeated_input_flags_handler(self, handler: Callable[[str], None]) -> None:
|
def set_repeated_input_flags_handler(self, _: Callable[[str], None]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the handler for repeated flags when entering a command
|
Public. Sets the handler for repeated flags when entering a command
|
||||||
:param handler: handler for repeated flags when entering a command
|
:param _: handler for repeated flags when entering a command
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._repeated_input_flags_handler = handler
|
self._repeated_input_flags_handler = _
|
||||||
|
|
||||||
|
|
||||||
def set_unknown_command_handler(self, handler: Callable[[str], None]) -> None:
|
def set_unknown_command_handler(self, _: Callable[[str], None]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the handler for unknown commands when entering a command
|
Public. Sets the handler for unknown commands when entering a command
|
||||||
:param handler: handler for unknown commands when entering a command
|
:param _: handler for unknown commands when entering a command
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._unknown_command_handler = handler
|
self._unknown_command_handler = _
|
||||||
|
|
||||||
|
|
||||||
def set_empty_command_handler(self, handler: Callable[[], None]) -> None:
|
def set_empty_command_handler(self, _: Callable[[], None]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the handler for empty commands when entering a command
|
Public. Sets the handler for empty commands when entering a command
|
||||||
:param handler: handler for empty commands when entering a command
|
:param _: handler for empty commands when entering a command
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._empty_input_command_handler = handler
|
self._empty_input_command_handler = _
|
||||||
|
|
||||||
|
|
||||||
def set_exit_command_handler(self, handler: Callable[[], None]) -> None:
|
def set_exit_command_handler(self, _: Callable[[], None]) -> None:
|
||||||
"""
|
"""
|
||||||
Public. Sets the handler for exit command when entering a command
|
Public. Sets the handler for exit command when entering a command
|
||||||
:param handler: handler for exit command when entering a command
|
:param _: handler for exit command when entering a command
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self._exit_command_handler = handler
|
self._exit_command_handler = _
|
||||||
|
|
||||||
|
|
||||||
def _print_command_group_description(self) -> None:
|
def _print_command_group_description(self) -> None:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from typing import Iterator
|
||||||
|
|
||||||
from argenta.router import Router
|
from argenta.router import Router
|
||||||
|
|
||||||
|
|
||||||
@@ -25,16 +27,8 @@ class RegisteredRouters:
|
|||||||
"""
|
"""
|
||||||
self._registered_routers.append(router)
|
self._registered_routers.append(router)
|
||||||
|
|
||||||
def add_registered_routers(self, *routers: Router) -> None:
|
def __iter__(self) -> Iterator[Router]:
|
||||||
"""
|
|
||||||
Private. Adds new registered routers
|
|
||||||
:param routers: registered routers
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
self._registered_routers.extend(routers)
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return iter(self._registered_routers)
|
return iter(self._registered_routers)
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self) -> Router:
|
||||||
return next(iter(self._registered_routers))
|
return next(iter(self._registered_routers))
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Callable
|
from typing import Callable, Iterator
|
||||||
|
|
||||||
from argenta.command import Command
|
from argenta.command import Command
|
||||||
from argenta.command.flag import InputFlags
|
from argenta.command.flag import InputFlags
|
||||||
@@ -64,16 +64,8 @@ class CommandHandlers:
|
|||||||
"""
|
"""
|
||||||
self.command_handlers.append(command_handler)
|
self.command_handlers.append(command_handler)
|
||||||
|
|
||||||
def add_handlers(self, *command_handlers: CommandHandler) -> None:
|
def __iter__(self) -> Iterator[CommandHandler]:
|
||||||
"""
|
|
||||||
Private. Extend a many CommandHandler to the list of CommandHandlers
|
|
||||||
:param command_handlers: many CommandHandler to be added
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
self.command_handlers.extend(command_handlers)
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return iter(self.command_handlers)
|
return iter(self.command_handlers)
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self) -> CommandHandler:
|
||||||
return next(iter(self.command_handlers))
|
return next(iter(self.command_handlers))
|
||||||
Reference in New Issue
Block a user