argenta 1.0.2__py3-none-any.whl → 1.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- argenta/app/defaults.py +2 -4
- argenta/app/models.py +59 -76
- argenta/router/entity.py +4 -6
- {argenta-1.0.2.dist-info → argenta-1.0.4.dist-info}/METADATA +16 -6
- {argenta-1.0.2.dist-info → argenta-1.0.4.dist-info}/RECORD +7 -7
- {argenta-1.0.2.dist-info → argenta-1.0.4.dist-info}/WHEEL +0 -0
- {argenta-1.0.2.dist-info → argenta-1.0.4.dist-info}/licenses/LICENSE +0 -0
argenta/app/defaults.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
from
|
1
|
+
from enum import Enum
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
class PredefinedMessages:
|
4
|
+
class PredefinedMessages(Enum):
|
6
5
|
"""
|
7
6
|
Public. A dataclass with predetermined messages for quick use
|
8
7
|
"""
|
9
|
-
|
10
8
|
USAGE = "[b dim]Usage[/b dim]: [i]<command> <[green]flags[/green]>[/i]"
|
11
9
|
HELP = "[b dim]Help[/b dim]: [i]<command>[/i] [b red]--help[/b red]"
|
12
10
|
AUTOCOMPLETE = "[b dim]Autocomplete[/b dim]: [i]<part>[/i] [bold]<tab>"
|
argenta/app/models.py
CHANGED
@@ -22,20 +22,18 @@ from argenta.response import Response
|
|
22
22
|
|
23
23
|
|
24
24
|
class BaseApp:
|
25
|
-
def __init__(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
print_func: Callable[[str], None],
|
38
|
-
) -> None:
|
25
|
+
def __init__(self,
|
26
|
+
prompt: str,
|
27
|
+
initial_message: str,
|
28
|
+
farewell_message: str,
|
29
|
+
exit_command: Command,
|
30
|
+
system_router_title: str | None,
|
31
|
+
ignore_command_register: bool,
|
32
|
+
dividing_line: StaticDividingLine | DynamicDividingLine,
|
33
|
+
repeat_command_groups: bool,
|
34
|
+
override_system_messages: bool,
|
35
|
+
autocompleter: AutoCompleter,
|
36
|
+
print_func: Callable[[str], None]) -> None:
|
39
37
|
self._prompt = prompt
|
40
38
|
self._print_func = print_func
|
41
39
|
self._exit_command = exit_command
|
@@ -49,30 +47,18 @@ class BaseApp:
|
|
49
47
|
self._farewell_message = farewell_message
|
50
48
|
self._initial_message = initial_message
|
51
49
|
|
52
|
-
self._description_message_gen: Callable[[str, str], str] = (
|
53
|
-
lambda command, description: f"[{command}] *=*=* {description}"
|
54
|
-
)
|
50
|
+
self._description_message_gen: Callable[[str, str], str] = (lambda command, description: f"[{command}] *=*=* {description}")
|
55
51
|
self._registered_routers: RegisteredRouters = RegisteredRouters()
|
56
52
|
self._messages_on_startup: list[str] = []
|
57
53
|
|
58
|
-
self.
|
54
|
+
self._all_registered_triggers_in_lower_case: list[str] = []
|
59
55
|
self._all_registered_triggers_in_default_case: list[str] = []
|
60
56
|
|
61
|
-
self._incorrect_input_syntax_handler: Callable[[str], None] = (
|
62
|
-
|
63
|
-
)
|
64
|
-
self.
|
65
|
-
|
66
|
-
)
|
67
|
-
self._empty_input_command_handler: Callable[[], None] = lambda: print_func(
|
68
|
-
"Empty input command"
|
69
|
-
)
|
70
|
-
self._unknown_command_handler: Callable[[InputCommand], None] = (
|
71
|
-
lambda command: print_func(f"Unknown command: {command.get_trigger()}")
|
72
|
-
)
|
73
|
-
self._exit_command_handler: Callable[[Response], None] = (
|
74
|
-
lambda response: print_func(self._farewell_message)
|
75
|
-
)
|
57
|
+
self._incorrect_input_syntax_handler: Callable[[str], None] = (lambda raw_command: print_func(f"Incorrect flag syntax: {raw_command}"))
|
58
|
+
self._repeated_input_flags_handler: Callable[[str], None] = (lambda raw_command: print_func(f"Repeated input flags: {raw_command}"))
|
59
|
+
self._empty_input_command_handler: Callable[[], None] = lambda: print_func("Empty input command")
|
60
|
+
self._unknown_command_handler: Callable[[InputCommand], None] = (lambda command: print_func(f"Unknown command: {command.get_trigger()}"))
|
61
|
+
self._exit_command_handler: Callable[[Response], None] = (lambda response: print_func(self._farewell_message))
|
76
62
|
|
77
63
|
def set_description_message_pattern(self, _: Callable[[str, str], str]) -> None:
|
78
64
|
"""
|
@@ -208,7 +194,7 @@ class BaseApp:
|
|
208
194
|
"""
|
209
195
|
input_command_trigger = command.get_trigger()
|
210
196
|
if self._ignore_command_register:
|
211
|
-
if input_command_trigger.lower() in self.
|
197
|
+
if input_command_trigger.lower() in self._all_registered_triggers_in_lower_case:
|
212
198
|
return False
|
213
199
|
else:
|
214
200
|
if input_command_trigger in self._all_registered_triggers_in_default_case:
|
@@ -249,7 +235,7 @@ class BaseApp:
|
|
249
235
|
|
250
236
|
def _most_similar_command(self, unknown_command: str) -> str | None:
|
251
237
|
all_commands = (
|
252
|
-
self.
|
238
|
+
self._all_registered_triggers_in_lower_case
|
253
239
|
if self._ignore_command_register
|
254
240
|
else self._all_registered_triggers_in_default_case
|
255
241
|
)
|
@@ -318,21 +304,22 @@ class BaseApp:
|
|
318
304
|
self._setup_system_router()
|
319
305
|
|
320
306
|
for router_entity in self._registered_routers:
|
321
|
-
self._all_registered_triggers_in_default_case.extend(
|
322
|
-
|
323
|
-
)
|
324
|
-
self._all_registered_triggers_in_default_case.extend(
|
325
|
-
router_entity.get_aliases()
|
326
|
-
)
|
307
|
+
self._all_registered_triggers_in_default_case.extend(router_entity.get_triggers())
|
308
|
+
self._all_registered_triggers_in_default_case.extend(router_entity.get_aliases())
|
327
309
|
|
328
|
-
self.
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
[x.lower() for x in router_entity.get_aliases()]
|
333
|
-
)
|
310
|
+
self._all_registered_triggers_in_lower_case.extend([x.lower() for x in router_entity.get_triggers()])
|
311
|
+
self._all_registered_triggers_in_lower_case.extend([x.lower() for x in router_entity.get_aliases()])
|
312
|
+
|
313
|
+
self._autocompleter.initial_setup(self._all_registered_triggers_in_lower_case)
|
334
314
|
|
335
|
-
self.
|
315
|
+
if self._ignore_command_register:
|
316
|
+
for cmd in set(self._all_registered_triggers_in_lower_case):
|
317
|
+
if self._all_registered_triggers_in_lower_case.count(cmd) != 1:
|
318
|
+
Console().print(f"\n[b red]WARNING:[/b red] Overlapping trigger or alias: [b blue]{cmd}[/b blue]")
|
319
|
+
else:
|
320
|
+
for cmd in set(self._all_registered_triggers_in_default_case):
|
321
|
+
if self._all_registered_triggers_in_default_case.count(cmd) != 1:
|
322
|
+
Console().print(f"\n[b red]WARNING:[/b red] Overlapping trigger or alias: [b blue]{cmd}[/b blue]")
|
336
323
|
|
337
324
|
if not self._override_system_messages:
|
338
325
|
self._setup_default_view()
|
@@ -349,20 +336,18 @@ class BaseApp:
|
|
349
336
|
|
350
337
|
|
351
338
|
class App(BaseApp):
|
352
|
-
def __init__(
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
print_func: Callable[[str], None] = Console().print,
|
365
|
-
) -> None:
|
339
|
+
def __init__(self,
|
340
|
+
prompt: str = "What do you want to do?\n",
|
341
|
+
initial_message: str = "Argenta\n",
|
342
|
+
farewell_message: str = "\nSee you\n",
|
343
|
+
exit_command: Command = Command("Q", "Exit command"),
|
344
|
+
system_router_title: str | None = "System points:",
|
345
|
+
ignore_command_register: bool = True,
|
346
|
+
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
347
|
+
repeat_command_groups: bool = True,
|
348
|
+
override_system_messages: bool = False,
|
349
|
+
autocompleter: AutoCompleter = AutoCompleter(),
|
350
|
+
print_func: Callable[[str], None] = Console().print) -> None:
|
366
351
|
"""
|
367
352
|
Public. The essence of the application itself.
|
368
353
|
Configures and manages all aspects of the behavior and presentation of the user interacting with the user
|
@@ -379,19 +364,17 @@ class App(BaseApp):
|
|
379
364
|
:param print_func: system messages text output function
|
380
365
|
:return: None
|
381
366
|
"""
|
382
|
-
super().__init__(
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
print_func=print_func,
|
394
|
-
)
|
367
|
+
super().__init__(prompt=prompt,
|
368
|
+
initial_message=initial_message,
|
369
|
+
farewell_message=farewell_message,
|
370
|
+
exit_command=exit_command,
|
371
|
+
system_router_title=system_router_title,
|
372
|
+
ignore_command_register=ignore_command_register,
|
373
|
+
dividing_line=dividing_line,
|
374
|
+
repeat_command_groups=repeat_command_groups,
|
375
|
+
override_system_messages=override_system_messages,
|
376
|
+
autocompleter=autocompleter,
|
377
|
+
print_func=print_func)
|
395
378
|
|
396
379
|
def run_polling(self) -> None:
|
397
380
|
"""
|
@@ -420,7 +403,7 @@ class App(BaseApp):
|
|
420
403
|
system_router.finds_appropriate_handler(input_command)
|
421
404
|
if self._ignore_command_register:
|
422
405
|
self._autocompleter.exit_setup(
|
423
|
-
self.
|
406
|
+
self._all_registered_triggers_in_lower_case
|
424
407
|
)
|
425
408
|
else:
|
426
409
|
self._autocompleter.exit_setup(
|
argenta/router/entity.py
CHANGED
@@ -192,14 +192,12 @@ class Router:
|
|
192
192
|
pass
|
193
193
|
else:
|
194
194
|
file_path: str = getsourcefile(func)
|
195
|
-
source_line: int = getsourcelines(func)[1]
|
195
|
+
source_line: int = getsourcelines(func)[1]
|
196
196
|
fprint = Console().print
|
197
|
-
fprint(
|
198
|
-
f'\nFile "{file_path}", line {source_line}\n[b red]WARNING:[/b red] [i]The typehint '
|
197
|
+
fprint(f'\nFile "{file_path}", line {source_line}\n[b red]WARNING:[/b red] [i]The typehint '
|
199
198
|
f"of argument([green]{transferred_arg}[/green]) passed to the handler is [/i][bold blue]{Response}[/bold blue],"
|
200
|
-
f" [i]but[/i] [bold blue]{arg_annotation}[/bold blue] [i]is specified[/i]
|
201
|
-
highlight=False
|
202
|
-
)
|
199
|
+
f" [i]but[/i] [bold blue]{arg_annotation}[/bold blue] [i]is specified[/i]",
|
200
|
+
highlight=False)
|
203
201
|
|
204
202
|
def set_command_register_ignore(self, _: bool) -> None:
|
205
203
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: argenta
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: Python library for building modular CLI applications
|
5
5
|
Author-email: kolo <kolo.is.main@gmail.com>
|
6
6
|
License: MIT
|
@@ -13,13 +13,15 @@ Description-Content-Type: text/markdown
|
|
13
13
|
|
14
14
|
# Argenta
|
15
15
|
|
16
|
-
###
|
16
|
+
### Library for creating modular CLI applications
|
17
|
+
|
18
|
+
#### RU - [README.ru.md](https://github.com/koloideal/Argenta/blob/kolo/README.ru.md)
|
17
19
|
|
18
20
|

|
19
21
|
|
20
22
|
---
|
21
23
|
|
22
|
-
#
|
24
|
+
# Installing
|
23
25
|
```bash
|
24
26
|
pip install argenta
|
25
27
|
```
|
@@ -30,9 +32,9 @@ poetry add argenta
|
|
30
32
|
|
31
33
|
---
|
32
34
|
|
33
|
-
#
|
35
|
+
# Quick start
|
34
36
|
|
35
|
-
|
37
|
+
An example of a simple application
|
36
38
|
```python
|
37
39
|
# routers.py
|
38
40
|
from argenta.router import Router
|
@@ -65,7 +67,15 @@ def main() -> None:
|
|
65
67
|
if __name__ == '__main__':
|
66
68
|
main()
|
67
69
|
```
|
68
|
-
|
70
|
+
|
71
|
+
---
|
72
|
+
|
73
|
+
# Features in development
|
74
|
+
|
75
|
+
- Full support for autocompleter on Linux
|
76
|
+
- Ability to configure stdout capture when handling input by the handler
|
77
|
+
|
78
|
+
## Full [docs](https://argenta-docs.vercel.app) | MIT 2025 kolo | made by [kolo](https://t.me/kolo_id)
|
69
79
|
|
70
80
|
|
71
81
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
argenta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
argenta/app/__init__.py,sha256=I8FTXU17ajDI-hbC6Rw0LxLmvDYipdQaos3v1pmu14E,57
|
3
|
-
argenta/app/defaults.py,sha256=
|
4
|
-
argenta/app/models.py,sha256=
|
3
|
+
argenta/app/defaults.py,sha256=nh_h5yxnXEGmsUwrb_BPdmiprshW6MDJwZyMS7p_AFw,373
|
4
|
+
argenta/app/models.py,sha256=k1hQEaYlh4X_qTaWKvUCJt7gdjIIJ68CtQoSPKgISYM,19797
|
5
5
|
argenta/app/autocompleter/__init__.py,sha256=VT_p3QA78UnczV7pYR2NnwQ0Atd8mnDUnLazvUQNqJk,93
|
6
6
|
argenta/app/autocompleter/entity.py,sha256=QgEZ2Tzfp9liWBCd-BdRpUE-ELUOxAhPpW7KBLVcPRE,3556
|
7
7
|
argenta/app/dividing_line/__init__.py,sha256=jJZDDZix8XYCAUWW4FzGJH0JmJlchYcx0FPWifjgv1I,147
|
@@ -27,11 +27,11 @@ argenta/response/entity.py,sha256=YcuKLnr7iiFewNqUH7bsdv-PccHfpitq-sm06tmSCjE,10
|
|
27
27
|
argenta/response/status.py,sha256=bWFMHvyIHpOA4LxUQFoSpld-F8gu183M9nY-zN-MiZM,244
|
28
28
|
argenta/router/__init__.py,sha256=rvqAx80IXHFdVw7cWBRGaTtb94a4OQQEsMJ5f7YA1gU,68
|
29
29
|
argenta/router/defaults.py,sha256=vvkwFYCQdwjtMntfyrJuisxFX8XxeyhDMA-RwteHZGg,87
|
30
|
-
argenta/router/entity.py,sha256=
|
30
|
+
argenta/router/entity.py,sha256=bu4t3E3POy4N6H8mBHcLuCEXlBQerzKj02Uw_56GsWE,9609
|
31
31
|
argenta/router/exceptions.py,sha256=5k0mTHYYItWHzGC0NU5oHHYrHxU0M5fEbO5wne_wFg8,860
|
32
32
|
argenta/router/command_handler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
argenta/router/command_handler/entity.py,sha256=xmHgbXBvD_-JMLpUPc5w3VVe-upTJ-y4lR13rUiiygo,2387
|
34
|
-
argenta-1.0.
|
35
|
-
argenta-1.0.
|
36
|
-
argenta-1.0.
|
37
|
-
argenta-1.0.
|
34
|
+
argenta-1.0.4.dist-info/METADATA,sha256=B6-Jb3HD1c2qqrigaTlmLE0ICqRUlYJSr654BfgVGac,1564
|
35
|
+
argenta-1.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
36
|
+
argenta-1.0.4.dist-info/licenses/LICENSE,sha256=zmqoGh2n5rReBv4s8wPxF_gZEZDgauJYSPMuPczgOiU,1082
|
37
|
+
argenta-1.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|