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