orionis 0.364.0__py3-none-any.whl → 0.366.0__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.
- orionis/{console → _console}/base/command.py +2 -2
- orionis/{console → _console}/commands/cache_clear.py +2 -2
- orionis/{console → _console}/commands/help.py +2 -2
- orionis/{console → _console}/commands/schedule_work.py +2 -2
- orionis/{console → _console}/commands/version.py +2 -2
- orionis/_console/output/console.py +587 -0
- orionis/{console → _console}/output/executor.py +1 -1
- orionis/{console → _console}/output/progress_bar.py +1 -1
- orionis/_contracts/console/base/command.py +1 -1
- orionis/_foundation/console/command_bootstrapper.py +1 -1
- orionis/_services/commands/reactor_commands_service.py +6 -6
- orionis/_services/commands/scheduler_service.py +1 -1
- orionis/console/dumper/contracts/dump.py +35 -0
- orionis/console/dumper/dump.py +627 -0
- orionis/console/dynamic/progress_bar.py +100 -0
- orionis/console/output/console.py +55 -89
- orionis/console/output/contracts/console.py +453 -0
- orionis/console/output/enums/__init__.py +5 -0
- orionis/foundation/application.py +2 -1
- orionis/foundation/providers/console_provider.py +21 -0
- orionis/foundation/providers/dumper_provider.py +21 -0
- orionis/foundation/providers/progress_bar_provider.py +21 -0
- orionis/metadata/framework.py +1 -1
- orionis/services/environment/core/dot_env.py +1 -1
- orionis/services/paths/contracts/resolver.py +4 -4
- orionis/services/paths/resolver.py +11 -0
- orionis/support/facades/console.py +15 -0
- orionis/support/facades/dumper.py +15 -0
- orionis/support/facades/progress_bar.py +15 -0
- orionis/support/formatter/exceptions/__init__.py +0 -0
- orionis/support/formatter/exceptions/contracts/__init__.py +0 -0
- orionis/{services → support}/formatter/exceptions/parser.py +1 -1
- orionis/{services → support}/formatter/serializer.py +1 -1
- orionis/support/patterns/__init__.py +0 -0
- orionis/support/patterns/singleton/__init__.py +5 -0
- orionis/test/output/dumper.py +2 -2
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/METADATA +1 -1
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/RECORD +73 -53
- tests/support/parsers/__init__.py +0 -0
- tests/support/parsers/mocks/__init__.py +0 -0
- tests/{services → support}/parsers/test_services_parser_exceptions.py +2 -2
- tests/support/patterns/__init__.py +0 -0
- tests/support/patterns/singleton/__init__.py +0 -0
- tests/{patterns → support/patterns}/singleton/test_patterns_singleton.py +1 -1
- /orionis/{console/base → _console}/__init__.py +0 -0
- /orionis/{console/commands → _console/base}/__init__.py +0 -0
- /orionis/{console → _console}/command_filter.py +0 -0
- /orionis/{console/exceptions → _console/commands}/__init__.py +0 -0
- /orionis/{patterns → _console/dumper}/__init__.py +0 -0
- /orionis/{console → _console}/dumper/dump_die.py +0 -0
- /orionis/{patterns/singleton → _console/exceptions}/__init__.py +0 -0
- /orionis/{console → _console}/exceptions/cli-orionis-value-error.py +0 -0
- /orionis/{console → _console}/exceptions/cli_exception.py +0 -0
- /orionis/{console → _console}/exceptions/cli_runtime_error.py +0 -0
- /orionis/{console → _console}/exceptions/cli_schedule_exception.py +0 -0
- /orionis/{console → _console}/kernel.py +0 -0
- /orionis/{services/formatter → _console/output}/__init__.py +0 -0
- /orionis/{console → _console}/parser.py +0 -0
- /orionis/{services/formatter/exceptions → console/dumper/contracts}/__init__.py +0 -0
- /orionis/{services/formatter/exceptions/contracts → console/dynamic}/__init__.py +0 -0
- {tests/patterns → orionis/console/dynamic/contracts}/__init__.py +0 -0
- /orionis/{_contracts/console/output → console/dynamic/contracts}/progress_bar.py +0 -0
- {tests/patterns/singleton → orionis/console/output/contracts}/__init__.py +0 -0
- /orionis/console/output/{styles.py → enums/styles.py} +0 -0
- {tests/services/parsers → orionis/support/facades}/__init__.py +0 -0
- {tests/services/parsers/mocks → orionis/support/formatter}/__init__.py +0 -0
- /orionis/{services → support}/formatter/exceptions/contracts/parser.py +0 -0
- /orionis/{patterns → support/patterns}/singleton/meta.py +0 -0
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/WHEEL +0 -0
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/top_level.txt +0 -0
- {orionis-0.364.0.dist-info → orionis-0.366.0.dist-info}/zip-safe +0 -0
- /tests/{services → support}/parsers/mocks/mock_custom_error.py +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from orionis.console.dynamic.contracts.progress_bar import IProgressBar
|
|
3
|
+
|
|
4
|
+
class ProgressBar(IProgressBar):
|
|
5
|
+
"""
|
|
6
|
+
A console-based progress bar implementation.
|
|
7
|
+
|
|
8
|
+
This class provides a simple text-based progress bar that updates
|
|
9
|
+
in place without clearing the console.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
total : int, optional
|
|
14
|
+
The total amount of progress (default is 100).
|
|
15
|
+
width : int, optional
|
|
16
|
+
The width of the progress bar in characters (default is 50).
|
|
17
|
+
|
|
18
|
+
Attributes
|
|
19
|
+
----------
|
|
20
|
+
total : int
|
|
21
|
+
The maximum progress value.
|
|
22
|
+
bar_width : int
|
|
23
|
+
The width of the progress bar in characters.
|
|
24
|
+
progress : int
|
|
25
|
+
The current progress value.
|
|
26
|
+
|
|
27
|
+
Methods
|
|
28
|
+
-------
|
|
29
|
+
start()
|
|
30
|
+
Initializes the progress bar to the starting state.
|
|
31
|
+
advance(increment=1)
|
|
32
|
+
Advances the progress bar by a given increment.
|
|
33
|
+
finish()
|
|
34
|
+
Completes the progress bar and moves to a new line.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __init__(self, total=100, width=50):
|
|
38
|
+
"""
|
|
39
|
+
Constructs all the necessary attributes for the progress bar object.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
total : int, optional
|
|
44
|
+
The total amount of progress (default is 100).
|
|
45
|
+
width : int, optional
|
|
46
|
+
The width of the progress bar in characters (default is 50).
|
|
47
|
+
"""
|
|
48
|
+
self.total = total
|
|
49
|
+
self.bar_width = width
|
|
50
|
+
self.progress = 0
|
|
51
|
+
|
|
52
|
+
def _update_bar(self):
|
|
53
|
+
"""
|
|
54
|
+
Updates the visual representation of the progress bar.
|
|
55
|
+
|
|
56
|
+
This method calculates the percentage of progress and updates the
|
|
57
|
+
console output accordingly.
|
|
58
|
+
"""
|
|
59
|
+
percent = self.progress / self.total
|
|
60
|
+
filled_length = int(self.bar_width * percent)
|
|
61
|
+
bar = f"[{'█' * filled_length}{'░' * (self.bar_width - filled_length)}] {int(percent * 100)}%"
|
|
62
|
+
|
|
63
|
+
# Move the cursor to the start of the line and overwrite it
|
|
64
|
+
sys.stdout.write("\r" + bar)
|
|
65
|
+
sys.stdout.flush()
|
|
66
|
+
|
|
67
|
+
def start(self):
|
|
68
|
+
"""
|
|
69
|
+
Initializes the progress bar to the starting state.
|
|
70
|
+
|
|
71
|
+
This method resets the progress to zero and displays the initial bar.
|
|
72
|
+
"""
|
|
73
|
+
self.progress = 0
|
|
74
|
+
self._update_bar()
|
|
75
|
+
|
|
76
|
+
def advance(self, increment=1):
|
|
77
|
+
"""
|
|
78
|
+
Advances the progress bar by a specific increment.
|
|
79
|
+
|
|
80
|
+
Parameters
|
|
81
|
+
----------
|
|
82
|
+
increment : int, optional
|
|
83
|
+
The amount by which the progress should be increased (default is 1).
|
|
84
|
+
"""
|
|
85
|
+
self.progress += increment
|
|
86
|
+
if self.progress > self.total:
|
|
87
|
+
self.progress = self.total
|
|
88
|
+
self._update_bar()
|
|
89
|
+
|
|
90
|
+
def finish(self):
|
|
91
|
+
"""
|
|
92
|
+
Completes the progress bar.
|
|
93
|
+
|
|
94
|
+
This method sets the progress to its maximum value, updates the bar,
|
|
95
|
+
and moves the cursor to a new line for cleaner output.
|
|
96
|
+
"""
|
|
97
|
+
self.progress = self.total
|
|
98
|
+
self._update_bar()
|
|
99
|
+
sys.stdout.write("\n")
|
|
100
|
+
sys.stdout.flush()
|
|
@@ -2,9 +2,9 @@ import datetime
|
|
|
2
2
|
import getpass
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
|
-
from orionis.console.output.
|
|
6
|
-
from orionis.
|
|
7
|
-
from orionis.
|
|
5
|
+
from orionis.console.output.enums import ANSIColors
|
|
6
|
+
from orionis.console.output.contracts.console import IConsole
|
|
7
|
+
from orionis.support.formatter.serializer import Parser
|
|
8
8
|
|
|
9
9
|
class Console(IConsole):
|
|
10
10
|
"""
|
|
@@ -14,8 +14,7 @@ class Console(IConsole):
|
|
|
14
14
|
optional timestamps, as well as general text formatting methods.
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
def _get_timestamp() -> str:
|
|
17
|
+
def __getTimestamp(self) -> str:
|
|
19
18
|
"""
|
|
20
19
|
Returns the current date and time formatted in a muted color.
|
|
21
20
|
|
|
@@ -26,8 +25,7 @@ class Console(IConsole):
|
|
|
26
25
|
"""
|
|
27
26
|
return f"{ANSIColors.TEXT_MUTED.value}{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{ANSIColors.DEFAULT.value}"
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
def _print_with_background(label: str, bg_color: ANSIColors, message: str, timestamp: bool):
|
|
28
|
+
def __printWithBackground(self, label: str, bg_color: ANSIColors, message: str, timestamp: bool):
|
|
31
29
|
"""
|
|
32
30
|
Prints a formatted message with a background color.
|
|
33
31
|
|
|
@@ -42,11 +40,10 @@ class Console(IConsole):
|
|
|
42
40
|
timestamp : bool
|
|
43
41
|
Whether to include a timestamp.
|
|
44
42
|
"""
|
|
45
|
-
str_time =
|
|
43
|
+
str_time = self.__getTimestamp() if timestamp else ''
|
|
46
44
|
print(f"{bg_color.value}{ANSIColors.TEXT_WHITE.value} {label} {ANSIColors.DEFAULT.value} {str_time} {message}{ANSIColors.DEFAULT.value}")
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
def _print_colored(message: str, text_color: ANSIColors):
|
|
46
|
+
def __printColored(self, message: str, text_color: ANSIColors):
|
|
50
47
|
"""
|
|
51
48
|
Prints a message with a specified text color.
|
|
52
49
|
|
|
@@ -59,8 +56,7 @@ class Console(IConsole):
|
|
|
59
56
|
"""
|
|
60
57
|
print(f"{text_color.value}{message}{ANSIColors.DEFAULT.value}")
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
def success(message: str, timestamp: bool = True):
|
|
59
|
+
def success(self, message: str, timestamp: bool = True):
|
|
64
60
|
"""
|
|
65
61
|
Prints a success message with a green background.
|
|
66
62
|
|
|
@@ -71,10 +67,9 @@ class Console(IConsole):
|
|
|
71
67
|
timestamp : bool, optional
|
|
72
68
|
Whether to include a timestamp (default is True).
|
|
73
69
|
"""
|
|
74
|
-
|
|
70
|
+
self.__printWithBackground("SUCCESS", ANSIColors.BG_SUCCESS, message, timestamp)
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
def textSuccess(message: str):
|
|
72
|
+
def textSuccess(self, message: str):
|
|
78
73
|
"""
|
|
79
74
|
Prints a success message in green.
|
|
80
75
|
|
|
@@ -83,10 +78,9 @@ class Console(IConsole):
|
|
|
83
78
|
message : str
|
|
84
79
|
The success message to print.
|
|
85
80
|
"""
|
|
86
|
-
|
|
81
|
+
self.__printColored(message, ANSIColors.TEXT_SUCCESS)
|
|
87
82
|
|
|
88
|
-
|
|
89
|
-
def textSuccessBold(message: str):
|
|
83
|
+
def textSuccessBold(self, message: str):
|
|
90
84
|
"""
|
|
91
85
|
Prints a bold success message in green.
|
|
92
86
|
|
|
@@ -95,10 +89,9 @@ class Console(IConsole):
|
|
|
95
89
|
message : str
|
|
96
90
|
The success message to print.
|
|
97
91
|
"""
|
|
98
|
-
|
|
92
|
+
self.__printColored(message, ANSIColors.TEXT_BOLD_SUCCESS)
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
def info(message: str, timestamp: bool = True):
|
|
94
|
+
def info(self, message: str, timestamp: bool = True):
|
|
102
95
|
"""
|
|
103
96
|
Prints an informational message with a blue background.
|
|
104
97
|
|
|
@@ -109,10 +102,9 @@ class Console(IConsole):
|
|
|
109
102
|
timestamp : bool, optional
|
|
110
103
|
Whether to include a timestamp (default is True).
|
|
111
104
|
"""
|
|
112
|
-
|
|
105
|
+
self.__printWithBackground("INFO", ANSIColors.BG_INFO, message, timestamp)
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
def textInfo(message: str):
|
|
107
|
+
def textInfo(self, message: str):
|
|
116
108
|
"""
|
|
117
109
|
Prints an informational message in blue.
|
|
118
110
|
|
|
@@ -121,10 +113,9 @@ class Console(IConsole):
|
|
|
121
113
|
message : str
|
|
122
114
|
The informational message to print.
|
|
123
115
|
"""
|
|
124
|
-
|
|
116
|
+
self.__printColored(message, ANSIColors.TEXT_INFO)
|
|
125
117
|
|
|
126
|
-
|
|
127
|
-
def textInfoBold(message: str):
|
|
118
|
+
def textInfoBold(self, message: str):
|
|
128
119
|
"""
|
|
129
120
|
Prints a bold informational message in blue.
|
|
130
121
|
|
|
@@ -133,10 +124,9 @@ class Console(IConsole):
|
|
|
133
124
|
message : str
|
|
134
125
|
The informational message to print.
|
|
135
126
|
"""
|
|
136
|
-
|
|
127
|
+
self.__printColored(message, ANSIColors.TEXT_BOLD_INFO)
|
|
137
128
|
|
|
138
|
-
|
|
139
|
-
def warning(message: str, timestamp: bool = True):
|
|
129
|
+
def warning(self, message: str, timestamp: bool = True):
|
|
140
130
|
"""
|
|
141
131
|
Prints a warning message with a yellow background.
|
|
142
132
|
|
|
@@ -147,10 +137,9 @@ class Console(IConsole):
|
|
|
147
137
|
timestamp : bool, optional
|
|
148
138
|
Whether to include a timestamp (default is True).
|
|
149
139
|
"""
|
|
150
|
-
|
|
140
|
+
self.__printWithBackground("WARNING", ANSIColors.BG_WARNING, message, timestamp)
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
def textWarning(message: str):
|
|
142
|
+
def textWarning(self, message: str):
|
|
154
143
|
"""
|
|
155
144
|
Prints a warning message in yellow.
|
|
156
145
|
|
|
@@ -159,10 +148,9 @@ class Console(IConsole):
|
|
|
159
148
|
message : str
|
|
160
149
|
The warning message to print.
|
|
161
150
|
"""
|
|
162
|
-
|
|
151
|
+
self.__printColored(message, ANSIColors.TEXT_WARNING)
|
|
163
152
|
|
|
164
|
-
|
|
165
|
-
def textWarningBold(message: str):
|
|
153
|
+
def textWarningBold(self, message: str):
|
|
166
154
|
"""
|
|
167
155
|
Prints a bold warning message in yellow.
|
|
168
156
|
|
|
@@ -171,10 +159,9 @@ class Console(IConsole):
|
|
|
171
159
|
message : str
|
|
172
160
|
The warning message to print.
|
|
173
161
|
"""
|
|
174
|
-
|
|
162
|
+
self.__printColored(message, ANSIColors.TEXT_BOLD_WARNING)
|
|
175
163
|
|
|
176
|
-
|
|
177
|
-
def fail(message: str, timestamp: bool = True):
|
|
164
|
+
def fail(self, message: str, timestamp: bool = True):
|
|
178
165
|
"""
|
|
179
166
|
Prints a failure message with a red background.
|
|
180
167
|
|
|
@@ -185,10 +172,9 @@ class Console(IConsole):
|
|
|
185
172
|
timestamp : bool, optional
|
|
186
173
|
Whether to include a timestamp (default is True).
|
|
187
174
|
"""
|
|
188
|
-
|
|
175
|
+
self.__printWithBackground("FAIL", ANSIColors.BG_FAIL, message, timestamp)
|
|
189
176
|
|
|
190
|
-
|
|
191
|
-
def error(message: str, timestamp: bool = True):
|
|
177
|
+
def error(self, message: str, timestamp: bool = True):
|
|
192
178
|
"""
|
|
193
179
|
Prints an error message with a red background.
|
|
194
180
|
|
|
@@ -199,10 +185,9 @@ class Console(IConsole):
|
|
|
199
185
|
timestamp : bool, optional
|
|
200
186
|
Whether to include a timestamp (default is True).
|
|
201
187
|
"""
|
|
202
|
-
|
|
188
|
+
self.__printWithBackground("ERROR", ANSIColors.BG_ERROR, message, timestamp)
|
|
203
189
|
|
|
204
|
-
|
|
205
|
-
def textError(message: str):
|
|
190
|
+
def textError(self, message: str):
|
|
206
191
|
"""
|
|
207
192
|
Prints an error message in red.
|
|
208
193
|
|
|
@@ -211,10 +196,9 @@ class Console(IConsole):
|
|
|
211
196
|
message : str
|
|
212
197
|
The error message to print.
|
|
213
198
|
"""
|
|
214
|
-
|
|
199
|
+
self.__printColored(message, ANSIColors.TEXT_ERROR)
|
|
215
200
|
|
|
216
|
-
|
|
217
|
-
def textErrorBold(message: str):
|
|
201
|
+
def textErrorBold(self, message: str):
|
|
218
202
|
"""
|
|
219
203
|
Prints a bold error message in red.
|
|
220
204
|
|
|
@@ -223,10 +207,9 @@ class Console(IConsole):
|
|
|
223
207
|
message : str
|
|
224
208
|
The error message to print.
|
|
225
209
|
"""
|
|
226
|
-
|
|
210
|
+
self.__printColored(message, ANSIColors.TEXT_BOLD_ERROR)
|
|
227
211
|
|
|
228
|
-
|
|
229
|
-
def textMuted(message: str):
|
|
212
|
+
def textMuted(self, message: str):
|
|
230
213
|
"""
|
|
231
214
|
Prints a muted (gray) message.
|
|
232
215
|
|
|
@@ -235,10 +218,9 @@ class Console(IConsole):
|
|
|
235
218
|
message : str
|
|
236
219
|
The message to print.
|
|
237
220
|
"""
|
|
238
|
-
|
|
221
|
+
self.__printColored(message, ANSIColors.TEXT_MUTED)
|
|
239
222
|
|
|
240
|
-
|
|
241
|
-
def textMutedBold(message: str):
|
|
223
|
+
def textMutedBold(self, message: str):
|
|
242
224
|
"""
|
|
243
225
|
Prints a bold muted (gray) message.
|
|
244
226
|
|
|
@@ -247,10 +229,9 @@ class Console(IConsole):
|
|
|
247
229
|
message : str
|
|
248
230
|
The message to print.
|
|
249
231
|
"""
|
|
250
|
-
|
|
232
|
+
self.__printColored(message, ANSIColors.TEXT_BOLD_MUTED)
|
|
251
233
|
|
|
252
|
-
|
|
253
|
-
def textUnderline(message: str):
|
|
234
|
+
def textUnderline(self, message: str):
|
|
254
235
|
"""
|
|
255
236
|
Prints an underlined message.
|
|
256
237
|
|
|
@@ -261,30 +242,26 @@ class Console(IConsole):
|
|
|
261
242
|
"""
|
|
262
243
|
print(f"{ANSIColors.TEXT_STYLE_UNDERLINE.value}{message}{ANSIColors.DEFAULT.value}")
|
|
263
244
|
|
|
264
|
-
|
|
265
|
-
def clear():
|
|
245
|
+
def clear(self):
|
|
266
246
|
"""
|
|
267
247
|
Clears the console screen.
|
|
268
248
|
"""
|
|
269
249
|
os.system('cls' if os.name == 'nt' else 'clear')
|
|
270
250
|
|
|
271
|
-
|
|
272
|
-
def clearLine():
|
|
251
|
+
def clearLine(self):
|
|
273
252
|
"""
|
|
274
253
|
Clears the current line in the console.
|
|
275
254
|
"""
|
|
276
255
|
sys.stdout.write("\r \r")
|
|
277
256
|
sys.stdout.flush()
|
|
278
257
|
|
|
279
|
-
|
|
280
|
-
def line():
|
|
258
|
+
def line(self):
|
|
281
259
|
"""
|
|
282
260
|
Prints a horizontal line in the console.
|
|
283
261
|
"""
|
|
284
262
|
print("\n", end="")
|
|
285
263
|
|
|
286
|
-
|
|
287
|
-
def newLine(count: int = 1):
|
|
264
|
+
def newLine(self, count: int = 1):
|
|
288
265
|
"""
|
|
289
266
|
Prints multiple new lines.
|
|
290
267
|
|
|
@@ -302,8 +279,7 @@ class Console(IConsole):
|
|
|
302
279
|
raise ValueError(f"Unsupported Value '{count}'")
|
|
303
280
|
print("\n" * count, end="")
|
|
304
281
|
|
|
305
|
-
|
|
306
|
-
def write(message: str):
|
|
282
|
+
def write(self, message: str):
|
|
307
283
|
"""
|
|
308
284
|
Prints a message without moving to the next line.
|
|
309
285
|
|
|
@@ -315,8 +291,7 @@ class Console(IConsole):
|
|
|
315
291
|
sys.stdout.write(f"{message}")
|
|
316
292
|
sys.stdout.flush()
|
|
317
293
|
|
|
318
|
-
|
|
319
|
-
def writeLine(message: str):
|
|
294
|
+
def writeLine(self, message: str):
|
|
320
295
|
"""
|
|
321
296
|
Prints a message and moves to the next line.
|
|
322
297
|
|
|
@@ -327,8 +302,7 @@ class Console(IConsole):
|
|
|
327
302
|
"""
|
|
328
303
|
print(f"{message}")
|
|
329
304
|
|
|
330
|
-
|
|
331
|
-
def ask(question: str) -> str:
|
|
305
|
+
def ask(self, question: str) -> str:
|
|
332
306
|
"""
|
|
333
307
|
Prompts the user for input with a message and returns the user's response.
|
|
334
308
|
|
|
@@ -344,8 +318,7 @@ class Console(IConsole):
|
|
|
344
318
|
"""
|
|
345
319
|
return input(f"{ANSIColors.TEXT_INFO.value}{str(question).strip()}{ANSIColors.DEFAULT.value} ")
|
|
346
320
|
|
|
347
|
-
|
|
348
|
-
def confirm(question: str, default: bool = False) -> bool:
|
|
321
|
+
def confirm(self, question: str, default: bool = False) -> bool:
|
|
349
322
|
"""
|
|
350
323
|
Asks a confirmation question and returns True or False based on the user's response.
|
|
351
324
|
|
|
@@ -366,8 +339,7 @@ class Console(IConsole):
|
|
|
366
339
|
response = input(f"{ANSIColors.TEXT_INFO.value}{str(question).strip()} (Y/n): {ANSIColors.DEFAULT.value} ").upper()
|
|
367
340
|
return default if not response else str(response).upper in ["Y", "YES"]
|
|
368
341
|
|
|
369
|
-
|
|
370
|
-
def secret(question: str) -> str:
|
|
342
|
+
def secret(self, question: str) -> str:
|
|
371
343
|
"""
|
|
372
344
|
Prompts the user for hidden input, typically used for password input.
|
|
373
345
|
|
|
@@ -383,8 +355,7 @@ class Console(IConsole):
|
|
|
383
355
|
"""
|
|
384
356
|
return getpass.getpass(f"{ANSIColors.TEXT_INFO.value}{str(question).strip()}{ANSIColors.DEFAULT.value} ")
|
|
385
357
|
|
|
386
|
-
|
|
387
|
-
def table(headers: list, rows: list):
|
|
358
|
+
def table(self, headers: list, rows: list):
|
|
388
359
|
"""
|
|
389
360
|
Prints a table in the console with the given headers and rows, with bold headers.
|
|
390
361
|
|
|
@@ -431,8 +402,7 @@ class Console(IConsole):
|
|
|
431
402
|
|
|
432
403
|
print(bottom_border)
|
|
433
404
|
|
|
434
|
-
|
|
435
|
-
def anticipate(question: str, options: list, default=None):
|
|
405
|
+
def anticipate(self, question: str, options: list, default=None):
|
|
436
406
|
"""
|
|
437
407
|
Provides autocomplete suggestions based on user input.
|
|
438
408
|
|
|
@@ -463,8 +433,7 @@ class Console(IConsole):
|
|
|
463
433
|
# Find the first option that starts with the input value, or use the default value
|
|
464
434
|
return next((option for option in options if option.startswith(input_value)), default or input_value)
|
|
465
435
|
|
|
466
|
-
|
|
467
|
-
def choice(question: str, choices: list, default_index: int = 0) -> str:
|
|
436
|
+
def choice(self, question: str, choices: list, default_index: int = 0) -> str:
|
|
468
437
|
"""
|
|
469
438
|
Allows the user to select an option from a list.
|
|
470
439
|
|
|
@@ -518,8 +487,7 @@ class Console(IConsole):
|
|
|
518
487
|
|
|
519
488
|
return choices[int(answer) - 1]
|
|
520
489
|
|
|
521
|
-
|
|
522
|
-
def exception(e) -> None:
|
|
490
|
+
def exception(self, e) -> None:
|
|
523
491
|
"""
|
|
524
492
|
Prints an exception message with detailed information.
|
|
525
493
|
|
|
@@ -558,8 +526,7 @@ class Console(IConsole):
|
|
|
558
526
|
|
|
559
527
|
print("▬" * len(f" [{error_type}] : {error_message}"))
|
|
560
528
|
|
|
561
|
-
|
|
562
|
-
def exitSuccess(message: str = None) -> None:
|
|
529
|
+
def exitSuccess(self, message: str = None) -> None:
|
|
563
530
|
"""
|
|
564
531
|
Exits the program with a success message.
|
|
565
532
|
|
|
@@ -569,11 +536,10 @@ class Console(IConsole):
|
|
|
569
536
|
The success message to print before exiting.
|
|
570
537
|
"""
|
|
571
538
|
if message:
|
|
572
|
-
|
|
539
|
+
self.success(message)
|
|
573
540
|
sys.exit(0)
|
|
574
541
|
|
|
575
|
-
|
|
576
|
-
def exitError(message: str = None) -> None:
|
|
542
|
+
def exitError(self, message: str = None) -> None:
|
|
577
543
|
"""
|
|
578
544
|
Exits the program with an error message.
|
|
579
545
|
|
|
@@ -583,5 +549,5 @@ class Console(IConsole):
|
|
|
583
549
|
The error message to print before exiting.
|
|
584
550
|
"""
|
|
585
551
|
if message:
|
|
586
|
-
|
|
552
|
+
self.error(message)
|
|
587
553
|
sys.exit(1)
|