Skip to content

Commit dd20cf7

Browse files
authored
Merge pull request #402 from splunk/validation-output_fixes
Validation output improvements
2 parents aceb70e + 17d4ac4 commit dd20cf7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

contentctl/input/director.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class Colors:
131131
DOCS = "📚" if sys.platform != "win32" else "?"
132132
BULB = "💡" if sys.platform != "win32" else "i"
133133
SEARCH = "🔍" if sys.platform != "win32" else "@"
134+
SPARKLE = "✨" if sys.platform != "win32" else "*"
134135
ZAP = "⚡" if sys.platform != "win32" else "!"
135136

136137

@@ -303,15 +304,18 @@ def createSecurityContent(
303304
)
304305

305306
if len(validation_errors) > 0:
307+
if sys.platform == "win32":
308+
sys.stdout.reconfigure(encoding="utf-8")
309+
306310
print("\n") # Clean separation
307311
print(f"{Colors.BOLD}{Colors.BRIGHT_MAGENTA}{'═' * 60}{Colors.END}")
308312
print(
309-
f"{Colors.BOLD}{Colors.BRIGHT_MAGENTA}{Colors.BLUE}{f'{Colors.SEARCH} Content Validation Summary':^60}{Colors.BRIGHT_MAGENTA}{Colors.END}"
313+
f"{Colors.BOLD}{Colors.BRIGHT_MAGENTA}{Colors.BLUE}{f'{Colors.SEARCH} Content Validation Summary':^59}{Colors.BRIGHT_MAGENTA}{Colors.END}"
310314
)
311315
print(f"{Colors.BOLD}{Colors.BRIGHT_MAGENTA}{'═' * 60}{Colors.END}\n")
312316

313317
print(
314-
f"{Colors.BOLD}{Colors.GREEN} Validation Completed{Colors.END} – Issues detected in {Colors.RED}{Colors.BOLD}{len(validation_errors)}{Colors.END} files.\n"
318+
f"{Colors.BOLD}{Colors.GREEN}{Colors.SPARKLE} Validation Completed{Colors.END} – Issues detected in {Colors.RED}{Colors.BOLD}{len(validation_errors)}{Colors.END} files.\n"
315319
)
316320

317321
for index, entry in enumerate(validation_errors, 1):
@@ -322,7 +326,7 @@ def createSecurityContent(
322326
number_emoji = f"{index}️⃣"
323327
print(f"{Colors.YELLOW}{'━' * width}{Colors.END}")
324328
print(
325-
f"{Colors.YELLOW}{Colors.BOLD} {number_emoji} File: {Colors.CYAN}{file_path}{Colors.END}{' ' * (width - len(str(file_path)) - 12)}{Colors.YELLOW}{Colors.END}"
329+
f"{Colors.YELLOW}{Colors.BOLD} {number_emoji} File: {Colors.CYAN}{file_path}{Colors.END}{' ' * (width - len(str(file_path)) - 9)}{Colors.YELLOW}{Colors.END}"
326330
)
327331
print(f"{Colors.YELLOW}{'━' * width}{Colors.END}")
328332

@@ -351,23 +355,25 @@ def createSecurityContent(
351355
)
352356
elif "Extra inputs" in error_msg:
353357
print(
354-
f" {Colors.BLUE} Unexpected Field: {err.get('loc', [''])[0]}{Colors.END}"
358+
f" {Colors.BLUE}{Colors.ERROR} Unexpected Field: {err.get('loc', [''])[0]}{Colors.END}"
355359
)
356360
elif "Failed to find" in error_msg:
357361
print(
358-
f" {Colors.RED}🔍 Missing Reference: {error_msg}{Colors.END}"
362+
f" {Colors.RED}{Colors.SEARCH} Missing Reference: {error_msg}{Colors.END}"
359363
)
360364
else:
361-
print(f" {Colors.RED}{error_msg}{Colors.END}")
365+
print(
366+
f" {Colors.RED}{Colors.ERROR} {error_msg}{Colors.END}"
367+
)
362368
else:
363-
print(f" {Colors.RED} {str(error)}{Colors.END}")
369+
print(f" {Colors.RED}{Colors.ERROR} {str(error)}{Colors.END}")
364370
print("")
365371

366372
# Clean footer with next steps
367373
max_width = max(60, max(len(str(e[0])) + 15 for e in validation_errors))
368374
print(f"{Colors.BOLD}{Colors.CYAN}{'═' * max_width}{Colors.END}")
369375
print(
370-
f"{Colors.BOLD}{Colors.CYAN}{Colors.BLUE}{'🎯 Next Steps':^{max_width}}{Colors.CYAN}{Colors.END}"
376+
f"{Colors.BOLD}{Colors.CYAN}{Colors.BLUE}{Colors.ARROW + ' Next Steps':^{max_width - 1}}{Colors.CYAN}{Colors.END}"
371377
)
372378
print(f"{Colors.BOLD}{Colors.CYAN}{'═' * max_width}{Colors.END}\n")
373379

0 commit comments

Comments
 (0)