systemprompt_runtime/startup_validation/
display.rs1#![allow(clippy::print_stdout)]
2
3use systemprompt_logging::services::cli::BrandColors;
4use systemprompt_traits::{StartupValidationReport, ValidationReport};
5
6pub fn display_validation_report(report: &StartupValidationReport) {
7 println!();
8 println!(
9 "{} {}",
10 BrandColors::stopped("✗"),
11 BrandColors::white_bold("Validation Failed")
12 );
13
14 if let Some(ref path) = report.profile_path {
15 println!(
16 " {} {}",
17 BrandColors::dim("Profile:"),
18 BrandColors::highlight(&path.display().to_string())
19 );
20 }
21
22 println!();
23 println!(
24 " {} error(s) found:",
25 BrandColors::stopped(&report.error_count().to_string())
26 );
27
28 for domain in &report.domains {
29 display_domain_errors(domain);
30 }
31
32 for ext in &report.extensions {
33 display_extension_errors(ext);
34 }
35
36 println!();
37}
38
39fn display_domain_errors(domain: &ValidationReport) {
40 if !domain.has_errors() {
41 return;
42 }
43
44 println!();
45 println!(
46 " {} {}",
47 BrandColors::stopped("▸"),
48 BrandColors::white_bold(&domain.domain)
49 );
50
51 for error in &domain.errors {
52 println!(" {} {}", BrandColors::dim("field:"), error.field);
53 println!(" {} {}", BrandColors::dim("error:"), error.message);
54 if let Some(ref path) = error.path {
55 println!(" {} {}", BrandColors::dim("path:"), path.display());
56 }
57 if let Some(ref suggestion) = error.suggestion {
58 println!(" {} {}", BrandColors::highlight("fix:"), suggestion);
59 }
60 }
61}
62
63fn display_extension_errors(ext: &ValidationReport) {
64 if !ext.has_errors() {
65 return;
66 }
67
68 println!();
69 println!(
70 " {} {}",
71 BrandColors::stopped("▸"),
72 BrandColors::white_bold(&ext.domain)
73 );
74
75 for error in &ext.errors {
76 println!(" {} {}", BrandColors::dim("field:"), error.field);
77 println!(" {} {}", BrandColors::dim("error:"), error.message);
78 }
79}
80
81pub fn display_validation_warnings(report: &StartupValidationReport) {
82 if report.warning_count() == 0 {
83 return;
84 }
85
86 println!(
87 " {} warning(s):",
88 BrandColors::starting(&report.warning_count().to_string())
89 );
90
91 for domain in &report.domains {
92 for warning in &domain.warnings {
93 println!();
94 println!(
95 " {} [{}] {}",
96 BrandColors::starting("⚠"),
97 domain.domain,
98 warning.field
99 );
100 println!(" {}", warning.message);
101 if let Some(ref suggestion) = warning.suggestion {
102 println!(" {} {}", BrandColors::highlight("fix:"), suggestion);
103 }
104 }
105 }
106
107 println!();
108}