argenta 1.1.1rc0__py3-none-any.whl → 1.1.2__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/__init__.py +6 -0
- argenta/app/__init__.py +10 -1
- argenta/app/autocompleter/entity.py +18 -19
- argenta/app/defaults.py +0 -1
- argenta/app/dividing_line/models.py +5 -5
- argenta/app/models.py +226 -140
- argenta/app/protocols.py +22 -0
- argenta/app/registered_routers/entity.py +7 -14
- argenta/command/__init__.py +11 -2
- argenta/command/exceptions.py +20 -13
- argenta/command/flag/__init__.py +5 -11
- argenta/command/flag/defaults.py +19 -24
- argenta/command/flag/flags/__init__.py +2 -8
- argenta/command/flag/flags/models.py +65 -49
- argenta/command/flag/models.py +78 -93
- argenta/command/models.py +100 -144
- argenta/di/__init__.py +2 -0
- argenta/di/integration.py +45 -0
- argenta/di/providers.py +14 -0
- argenta/metrics/main.py +2 -2
- argenta/orchestrator/__init__.py +2 -2
- argenta/orchestrator/argparser/__init__.py +6 -1
- argenta/orchestrator/argparser/arguments/__init__.py +3 -3
- argenta/orchestrator/argparser/arguments/models.py +61 -35
- argenta/orchestrator/argparser/entity.py +56 -37
- argenta/orchestrator/entity.py +20 -18
- argenta/py.typed +0 -0
- argenta/response/__init__.py +2 -2
- argenta/response/entity.py +17 -18
- argenta/response/status.py +12 -1
- argenta/router/__init__.py +2 -2
- argenta/router/command_handler/entity.py +9 -27
- argenta/router/entity.py +133 -160
- argenta/router/exceptions.py +9 -12
- {argenta-1.1.1rc0.dist-info → argenta-1.1.2.dist-info}/METADATA +12 -5
- argenta-1.1.2.dist-info/RECORD +44 -0
- argenta-1.1.1rc0.dist-info/RECORD +0 -39
- {argenta-1.1.1rc0.dist-info → argenta-1.1.2.dist-info}/WHEEL +0 -0
- {argenta-1.1.1rc0.dist-info → argenta-1.1.2.dist-info}/licenses/LICENSE +0 -0
argenta/__init__.py
CHANGED
argenta/app/__init__.py
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
-
__all__ = [
|
1
|
+
__all__ = [
|
2
|
+
"App",
|
3
|
+
"PredefinedMessages",
|
4
|
+
"DynamicDividingLine",
|
5
|
+
"StaticDividingLine",
|
6
|
+
"AutoCompleter"
|
7
|
+
]
|
2
8
|
|
3
9
|
from argenta.app.models import App
|
10
|
+
from argenta.app.defaults import PredefinedMessages
|
11
|
+
from argenta.app.dividing_line.models import DynamicDividingLine, StaticDividingLine
|
12
|
+
from argenta.app.autocompleter.entity import AutoCompleter
|
@@ -13,10 +13,10 @@ class AutoCompleter:
|
|
13
13
|
:param autocomplete_button: the button for auto-completion
|
14
14
|
:return: None
|
15
15
|
"""
|
16
|
-
self.history_filename = history_filename
|
17
|
-
self.autocomplete_button = autocomplete_button
|
16
|
+
self.history_filename: str | None = history_filename
|
17
|
+
self.autocomplete_button: str = autocomplete_button
|
18
18
|
|
19
|
-
def _complete(self, text, state) -> str | None:
|
19
|
+
def _complete(self, text: str, state: int) -> str | None:
|
20
20
|
"""
|
21
21
|
Private. Auto-completion function
|
22
22
|
:param text: part of the command being entered
|
@@ -24,7 +24,7 @@ class AutoCompleter:
|
|
24
24
|
:return: the desired candidate as str or None
|
25
25
|
"""
|
26
26
|
matches: list[str] = sorted(
|
27
|
-
cmd for cmd in
|
27
|
+
cmd for cmd in _get_history_items() if cmd.startswith(text)
|
28
28
|
)
|
29
29
|
if len(matches) > 1:
|
30
30
|
common_prefix = matches[0]
|
@@ -38,7 +38,7 @@ class AutoCompleter:
|
|
38
38
|
i += 1
|
39
39
|
common_prefix = common_prefix[:i]
|
40
40
|
if state == 0:
|
41
|
-
readline.insert_text(common_prefix[len(text) :])
|
41
|
+
readline.insert_text(common_prefix[len(text) :])
|
42
42
|
readline.redisplay()
|
43
43
|
return None
|
44
44
|
elif len(matches) == 1:
|
@@ -54,10 +54,10 @@ class AutoCompleter:
|
|
54
54
|
"""
|
55
55
|
if self.history_filename:
|
56
56
|
if os.path.exists(self.history_filename):
|
57
|
-
readline.read_history_file(self.history_filename)
|
57
|
+
readline.read_history_file(self.history_filename)
|
58
58
|
else:
|
59
59
|
for line in all_commands:
|
60
|
-
readline.add_history(line)
|
60
|
+
readline.add_history(line)
|
61
61
|
|
62
62
|
readline.set_completer(self._complete)
|
63
63
|
readline.set_completer_delims(readline.get_completer_delims().replace(" ", ""))
|
@@ -69,7 +69,7 @@ class AutoCompleter:
|
|
69
69
|
:return: None
|
70
70
|
"""
|
71
71
|
if self.history_filename:
|
72
|
-
readline.write_history_file(self.history_filename)
|
72
|
+
readline.write_history_file(self.history_filename)
|
73
73
|
with open(self.history_filename, "r") as history_file:
|
74
74
|
raw_history = history_file.read()
|
75
75
|
pretty_history: list[str] = []
|
@@ -77,15 +77,14 @@ class AutoCompleter:
|
|
77
77
|
if line.split()[0] in all_commands:
|
78
78
|
pretty_history.append(line)
|
79
79
|
with open(self.history_filename, "w") as history_file:
|
80
|
-
history_file.write("\n".join(pretty_history))
|
80
|
+
_ = history_file.write("\n".join(pretty_history))
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
]
|
82
|
+
def _get_history_items() -> list[str] | list[Never]:
|
83
|
+
"""
|
84
|
+
Private. Returns a list of all commands entered by the user
|
85
|
+
:return: all commands entered by the user as list[str] | list[Never]
|
86
|
+
"""
|
87
|
+
return [
|
88
|
+
readline.get_history_item(i)
|
89
|
+
for i in range(1, readline.get_current_history_length() + 1)
|
90
|
+
]
|
argenta/app/defaults.py
CHANGED
@@ -5,7 +5,6 @@ class PredefinedMessages(StrEnum):
|
|
5
5
|
"""
|
6
6
|
Public. A dataclass with predetermined messages for quick use
|
7
7
|
"""
|
8
|
-
|
9
8
|
USAGE = "[b dim]Usage[/b dim]: [i]<command> <[green]flags[/green]>[/i]"
|
10
9
|
HELP = "[b dim]Help[/b dim]: [i]<command>[/i] [b red]--help[/b red]"
|
11
10
|
AUTOCOMPLETE = "[b dim]Autocomplete[/b dim]: [i]<part>[/i] [bold]<tab>"
|
@@ -8,7 +8,7 @@ class BaseDividingLine(ABC):
|
|
8
8
|
:param unit_part: the single part of the dividing line
|
9
9
|
:return: None
|
10
10
|
"""
|
11
|
-
self._unit_part = unit_part
|
11
|
+
self._unit_part: str = unit_part
|
12
12
|
|
13
13
|
def get_unit_part(self) -> str:
|
14
14
|
"""
|
@@ -22,7 +22,7 @@ class BaseDividingLine(ABC):
|
|
22
22
|
|
23
23
|
|
24
24
|
class StaticDividingLine(BaseDividingLine):
|
25
|
-
def __init__(self, unit_part: str = "-", length: int = 25) -> None:
|
25
|
+
def __init__(self, unit_part: str = "-", *, length: int = 25) -> None:
|
26
26
|
"""
|
27
27
|
Public. The static dividing line
|
28
28
|
:param unit_part: the single part of the dividing line
|
@@ -30,9 +30,9 @@ class StaticDividingLine(BaseDividingLine):
|
|
30
30
|
:return: None
|
31
31
|
"""
|
32
32
|
super().__init__(unit_part)
|
33
|
-
self.length = length
|
33
|
+
self.length: int = length
|
34
34
|
|
35
|
-
def get_full_static_line(self, is_override: bool) -> str:
|
35
|
+
def get_full_static_line(self, *, is_override: bool) -> str:
|
36
36
|
"""
|
37
37
|
Private. Returns the full line of the dividing line
|
38
38
|
:param is_override: has the default text layout been redefined
|
@@ -53,7 +53,7 @@ class DynamicDividingLine(BaseDividingLine):
|
|
53
53
|
"""
|
54
54
|
super().__init__(unit_part)
|
55
55
|
|
56
|
-
def get_full_dynamic_line(self, length: int, is_override: bool) -> str:
|
56
|
+
def get_full_dynamic_line(self, *, length: int, is_override: bool) -> str:
|
57
57
|
"""
|
58
58
|
Private. Returns the full line of the dividing line
|
59
59
|
:param length: the length of the dividing line
|