mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
v0.3.9
This commit is contained in:
+2
-16
@@ -1,17 +1,3 @@
|
||||
import readline
|
||||
from typing import cast, Literal
|
||||
|
||||
def startup_hook():
|
||||
readline.insert_text('from startup_hook')
|
||||
|
||||
def pre_input_hook():
|
||||
readline.insert_text('from pre_input_hook')
|
||||
readline.redisplay()
|
||||
|
||||
readline.set_startup_hook(startup_hook)
|
||||
readline.set_pre_input_hook(pre_input_hook)
|
||||
readline.parse_and_bind('tab: complete')
|
||||
|
||||
line = ''
|
||||
while line != 'stop':
|
||||
line = input('!("stop" to quit) Ввод текста: => ')
|
||||
print (f'Отправка: {line}')
|
||||
print(cast(Literal['-', '--', '---'], '----'))
|
||||
@@ -2,9 +2,9 @@ import re
|
||||
from pprint import pprint
|
||||
from rich.console import Console
|
||||
|
||||
from argenta.command.entity import Command
|
||||
from argenta.command.params.flag.entity import Flag
|
||||
from argenta.command.params.flag.flags_group.entity import FlagsGroup
|
||||
from argenta.command import Command
|
||||
from argenta.command.flag import Flag, FlagsGroup
|
||||
from argenta.command.flag.defaults import host_flag, port_flag
|
||||
from argenta.router import Router
|
||||
from .handlers_implementation.help_command import help_command
|
||||
|
||||
@@ -18,21 +18,12 @@ settings_router: Router = Router(title='Settings points:')
|
||||
console = Console()
|
||||
|
||||
|
||||
flags = FlagsGroup(flags=[
|
||||
Flag(flag_name='host',
|
||||
flag_prefix='--',
|
||||
possible_flag_values=re.compile(r'^192.168.\d{1,3}.\d{1,3}$')),
|
||||
Flag(flag_name='port',
|
||||
flag_prefix='--', )
|
||||
])
|
||||
|
||||
|
||||
@work_router.command(Command(trigger='0', description='Get Help'))
|
||||
def command_help():
|
||||
help_command()
|
||||
|
||||
|
||||
@work_router.command(Command(trigger='--gbP', description='Start Solving', flags=flags))
|
||||
@work_router.command(Command(trigger='j', description='Start Solving', flags=FlagsGroup(host_flag, port_flag)))
|
||||
def command_start_solving(args: dict):
|
||||
print('Solving...')
|
||||
pprint(args)
|
||||
|
||||
@@ -3,16 +3,13 @@ from art import text2art
|
||||
from rich.console import Console
|
||||
|
||||
from argenta.app import App
|
||||
from argenta.router import Router
|
||||
from argenta.command import Command
|
||||
from argenta.command.params.flag import Flag, FlagsGroup
|
||||
|
||||
|
||||
app: App = App(prompt='[italic white bold]What do you want to do(enter number of action)?',
|
||||
line_separate=f'\n{"[bold green]-[/bold green][bold red]-[/bold red]"*25}\n',
|
||||
print_func=Console().print,
|
||||
command_group_description_separate='',
|
||||
repeat_command_groups=True)
|
||||
repeat_command_groups=True,
|
||||
ignore_exit_command_register=False)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -29,7 +26,7 @@ def main():
|
||||
app.set_farewell_message(goodbye_message)
|
||||
|
||||
app.set_invalid_input_flags_handler(lambda raw_command: print(f"Invalid input flags: {raw_command}"))
|
||||
app.set_unknown_command_handler(lambda command: print(f"Unknown command: {command.get_string_entity()}"))
|
||||
app.set_unknown_command_handler(lambda command: print(f"Unknown command: {command.get_trigger()}"))
|
||||
app.set_repeated_input_flags_handler(lambda raw_command: print(f"Repeated input flags: {raw_command}"))
|
||||
|
||||
app.set_description_message_pattern('[bold red][{command}][/bold red] [blue]*=*=*[/blue] [bold yellow italic]{description}')
|
||||
|
||||
Reference in New Issue
Block a user