minecraft-datapack-language 15.4.0__py3-none-any.whl → 15.4.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.
- minecraft_datapack_language/_version.py +2 -2
- minecraft_datapack_language/cli_build.py +181 -1025
- minecraft_datapack_language/cli_colors.py +264 -0
- minecraft_datapack_language/cli_help.py +371 -404
- minecraft_datapack_language/mdl_errors.py +112 -117
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/METADATA +1 -1
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/RECORD +11 -10
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/WHEEL +0 -0
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/entry_points.txt +0 -0
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/licenses/LICENSE +0 -0
- {minecraft_datapack_language-15.4.0.dist-info → minecraft_datapack_language-15.4.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,264 @@
|
|
1
|
+
"""
|
2
|
+
CLI Color Utilities - Windows-compatible color system for MDL CLI
|
3
|
+
Provides vibrant colors without unicode characters for maximum readability
|
4
|
+
"""
|
5
|
+
|
6
|
+
import os
|
7
|
+
import sys
|
8
|
+
from typing import Optional
|
9
|
+
|
10
|
+
|
11
|
+
class Colors:
|
12
|
+
"""Color constants for CLI output - Windows compatible."""
|
13
|
+
|
14
|
+
# Basic colors using ANSI escape codes
|
15
|
+
RESET = "\033[0m"
|
16
|
+
BOLD = "\033[1m"
|
17
|
+
DIM = "\033[2m"
|
18
|
+
UNDERLINE = "\033[4m"
|
19
|
+
BLINK = "\033[5m"
|
20
|
+
REVERSE = "\033[7m"
|
21
|
+
HIDDEN = "\033[8m"
|
22
|
+
|
23
|
+
# Foreground colors
|
24
|
+
BLACK = "\033[30m"
|
25
|
+
RED = "\033[31m"
|
26
|
+
GREEN = "\033[32m"
|
27
|
+
YELLOW = "\033[33m"
|
28
|
+
BLUE = "\033[34m"
|
29
|
+
MAGENTA = "\033[35m"
|
30
|
+
CYAN = "\033[36m"
|
31
|
+
WHITE = "\033[37m"
|
32
|
+
|
33
|
+
# Bright foreground colors
|
34
|
+
BRIGHT_BLACK = "\033[90m"
|
35
|
+
BRIGHT_RED = "\033[91m"
|
36
|
+
BRIGHT_GREEN = "\033[92m"
|
37
|
+
BRIGHT_YELLOW = "\033[93m"
|
38
|
+
BRIGHT_BLUE = "\033[94m"
|
39
|
+
BRIGHT_MAGENTA = "\033[95m"
|
40
|
+
BRIGHT_CYAN = "\033[96m"
|
41
|
+
BRIGHT_WHITE = "\033[97m"
|
42
|
+
|
43
|
+
# Background colors
|
44
|
+
BG_BLACK = "\033[40m"
|
45
|
+
BG_RED = "\033[41m"
|
46
|
+
BG_GREEN = "\033[42m"
|
47
|
+
BG_YELLOW = "\033[43m"
|
48
|
+
BG_BLUE = "\033[44m"
|
49
|
+
BG_MAGENTA = "\033[45m"
|
50
|
+
BG_CYAN = "\033[46m"
|
51
|
+
BG_WHITE = "\033[47m"
|
52
|
+
|
53
|
+
# Bright background colors
|
54
|
+
BG_BRIGHT_BLACK = "\033[100m"
|
55
|
+
BG_BRIGHT_RED = "\033[101m"
|
56
|
+
BG_BRIGHT_GREEN = "\033[102m"
|
57
|
+
BG_BRIGHT_YELLOW = "\033[103m"
|
58
|
+
BG_BRIGHT_BLUE = "\033[104m"
|
59
|
+
BG_BRIGHT_MAGENTA = "\033[105m"
|
60
|
+
BG_BRIGHT_CYAN = "\033[106m"
|
61
|
+
BG_BRIGHT_WHITE = "\033[107m"
|
62
|
+
|
63
|
+
|
64
|
+
class ColorFormatter:
|
65
|
+
"""Formats text with colors and styling for CLI output."""
|
66
|
+
|
67
|
+
def __init__(self, force_colors: bool = False):
|
68
|
+
"""Initialize color formatter.
|
69
|
+
|
70
|
+
Args:
|
71
|
+
force_colors: If True, force colors even when not supported
|
72
|
+
"""
|
73
|
+
self.colors_enabled = self._check_color_support() or force_colors
|
74
|
+
|
75
|
+
def _check_color_support(self) -> bool:
|
76
|
+
"""Check if the terminal supports colors."""
|
77
|
+
# Check if we're on Windows
|
78
|
+
if os.name == 'nt':
|
79
|
+
# On Windows, check if we're in a modern terminal
|
80
|
+
try:
|
81
|
+
import colorama
|
82
|
+
return True
|
83
|
+
except ImportError:
|
84
|
+
# Check if we're in a modern Windows terminal
|
85
|
+
return 'TERM' in os.environ and os.environ['TERM'] != 'dumb'
|
86
|
+
else:
|
87
|
+
# On Unix-like systems, check if we have a TTY
|
88
|
+
return hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
|
89
|
+
|
90
|
+
def _format(self, text: str, *colors: str) -> str:
|
91
|
+
"""Format text with colors if enabled."""
|
92
|
+
if not self.colors_enabled:
|
93
|
+
return text
|
94
|
+
|
95
|
+
color_codes = ''.join(colors)
|
96
|
+
return f"{color_codes}{text}{Colors.RESET}"
|
97
|
+
|
98
|
+
def header(self, text: str) -> str:
|
99
|
+
"""Format a header with bright cyan and bold."""
|
100
|
+
return self._format(text, Colors.BRIGHT_CYAN, Colors.BOLD)
|
101
|
+
|
102
|
+
def title(self, text: str) -> str:
|
103
|
+
"""Format a title with bright blue and bold."""
|
104
|
+
return self._format(text, Colors.BRIGHT_BLUE, Colors.BOLD)
|
105
|
+
|
106
|
+
def command(self, text: str) -> str:
|
107
|
+
"""Format a command with bright green."""
|
108
|
+
return self._format(text, Colors.BRIGHT_GREEN)
|
109
|
+
|
110
|
+
def option(self, text: str) -> str:
|
111
|
+
"""Format an option with bright yellow."""
|
112
|
+
return self._format(text, Colors.BRIGHT_YELLOW)
|
113
|
+
|
114
|
+
def success(self, text: str) -> str:
|
115
|
+
"""Format success message with bright green."""
|
116
|
+
return self._format(text, Colors.BRIGHT_GREEN)
|
117
|
+
|
118
|
+
def warning(self, text: str) -> str:
|
119
|
+
"""Format warning message with bright yellow."""
|
120
|
+
return self._format(text, Colors.BRIGHT_YELLOW)
|
121
|
+
|
122
|
+
def error(self, text: str) -> str:
|
123
|
+
"""Format error message with bright red."""
|
124
|
+
return self._format(text, Colors.BRIGHT_RED)
|
125
|
+
|
126
|
+
def info(self, text: str) -> str:
|
127
|
+
"""Format info message with bright cyan."""
|
128
|
+
return self._format(text, Colors.BRIGHT_CYAN)
|
129
|
+
|
130
|
+
def highlight(self, text: str) -> str:
|
131
|
+
"""Format highlighted text with bright magenta."""
|
132
|
+
return self._format(text, Colors.BRIGHT_MAGENTA)
|
133
|
+
|
134
|
+
def dim(self, text: str) -> str:
|
135
|
+
"""Format dimmed text."""
|
136
|
+
return self._format(text, Colors.DIM)
|
137
|
+
|
138
|
+
def bold(self, text: str) -> str:
|
139
|
+
"""Format bold text."""
|
140
|
+
return self._format(text, Colors.BOLD)
|
141
|
+
|
142
|
+
def underline(self, text: str) -> str:
|
143
|
+
"""Format underlined text."""
|
144
|
+
return self._format(text, Colors.UNDERLINE)
|
145
|
+
|
146
|
+
def separator(self, char: str = "=", length: int = 60) -> str:
|
147
|
+
"""Create a colored separator line."""
|
148
|
+
separator_line = char * length
|
149
|
+
return self._format(separator_line, Colors.BRIGHT_BLUE)
|
150
|
+
|
151
|
+
def section(self, title: str, char: str = "=") -> str:
|
152
|
+
"""Create a colored section header."""
|
153
|
+
line_length = max(60, len(title) + 4)
|
154
|
+
left_pad = (line_length - len(title)) // 2
|
155
|
+
right_pad = line_length - len(title) - left_pad
|
156
|
+
|
157
|
+
section = f"{char * left_pad} {title} {char * right_pad}"
|
158
|
+
return self._format(section, Colors.BRIGHT_BLUE, Colors.BOLD)
|
159
|
+
|
160
|
+
def bullet(self, text: str, bullet_char: str = "•") -> str:
|
161
|
+
"""Format a bullet point."""
|
162
|
+
return self._format(f"{bullet_char} {text}", Colors.BRIGHT_WHITE)
|
163
|
+
|
164
|
+
def code(self, text: str) -> str:
|
165
|
+
"""Format code or technical text."""
|
166
|
+
return self._format(text, Colors.BRIGHT_WHITE, Colors.BG_BRIGHT_BLACK)
|
167
|
+
|
168
|
+
def file_path(self, text: str) -> str:
|
169
|
+
"""Format file paths."""
|
170
|
+
return self._format(text, Colors.BRIGHT_CYAN)
|
171
|
+
|
172
|
+
def line_number(self, text: str) -> str:
|
173
|
+
"""Format line numbers."""
|
174
|
+
return self._format(text, Colors.BRIGHT_YELLOW)
|
175
|
+
|
176
|
+
def column_number(self, text: str) -> str:
|
177
|
+
"""Format column numbers."""
|
178
|
+
return self._format(text, Colors.BRIGHT_YELLOW)
|
179
|
+
|
180
|
+
def error_type(self, text: str) -> str:
|
181
|
+
"""Format error type labels."""
|
182
|
+
return self._format(text, Colors.BRIGHT_RED, Colors.BOLD)
|
183
|
+
|
184
|
+
def suggestion(self, text: str) -> str:
|
185
|
+
"""Format suggestions."""
|
186
|
+
return self._format(text, Colors.BRIGHT_GREEN, Colors.BOLD)
|
187
|
+
|
188
|
+
def context(self, text: str) -> str:
|
189
|
+
"""Format context information."""
|
190
|
+
return self._format(text, Colors.DIM)
|
191
|
+
|
192
|
+
|
193
|
+
# Global color formatter instance
|
194
|
+
color = ColorFormatter()
|
195
|
+
|
196
|
+
|
197
|
+
def print_header(text: str):
|
198
|
+
"""Print a formatted header."""
|
199
|
+
print(color.header(text))
|
200
|
+
|
201
|
+
|
202
|
+
def print_title(text: str):
|
203
|
+
"""Print a formatted title."""
|
204
|
+
print(color.title(text))
|
205
|
+
|
206
|
+
|
207
|
+
def print_section(title: str):
|
208
|
+
"""Print a formatted section."""
|
209
|
+
print(color.section(title))
|
210
|
+
|
211
|
+
|
212
|
+
def print_separator(char: str = "=", length: int = 60):
|
213
|
+
"""Print a formatted separator."""
|
214
|
+
print(color.separator(char, length))
|
215
|
+
|
216
|
+
|
217
|
+
def print_success(text: str):
|
218
|
+
"""Print a success message."""
|
219
|
+
print(color.success(text))
|
220
|
+
|
221
|
+
|
222
|
+
def print_warning(text: str):
|
223
|
+
"""Print a warning message."""
|
224
|
+
print(color.warning(text))
|
225
|
+
|
226
|
+
|
227
|
+
def print_error(text: str):
|
228
|
+
"""Print an error message."""
|
229
|
+
print(color.error(text))
|
230
|
+
|
231
|
+
|
232
|
+
def print_info(text: str):
|
233
|
+
"""Print an info message."""
|
234
|
+
print(color.info(text))
|
235
|
+
|
236
|
+
|
237
|
+
def print_bullet(text: str):
|
238
|
+
"""Print a bullet point."""
|
239
|
+
print(color.bullet(text))
|
240
|
+
|
241
|
+
|
242
|
+
def print_code(text: str):
|
243
|
+
"""Print formatted code."""
|
244
|
+
print(color.code(text))
|
245
|
+
|
246
|
+
|
247
|
+
def print_file_path(text: str):
|
248
|
+
"""Print a formatted file path."""
|
249
|
+
print(color.file_path(text))
|
250
|
+
|
251
|
+
|
252
|
+
def print_error_type(text: str):
|
253
|
+
"""Print a formatted error type."""
|
254
|
+
print(color.error_type(text))
|
255
|
+
|
256
|
+
|
257
|
+
def print_suggestion(text: str):
|
258
|
+
"""Print a formatted suggestion."""
|
259
|
+
print(color.suggestion(text))
|
260
|
+
|
261
|
+
|
262
|
+
def print_context(text: str):
|
263
|
+
"""Print formatted context."""
|
264
|
+
print(color.context(text))
|