wowlab_engine/cli/audit/
output.rs1use wowlab_common::output;
4use wowlab_engine_application::{AuditIssue, SpecAudit};
5
6pub(super) fn print_spec(audit: &SpecAudit) {
7 let has_errors = !audit.errors.is_empty();
8 let has_warnings = !audit.warnings.is_empty();
9
10 let total_ids = audit.spell_count
11 + audit.aura_count
12 + audit.talent_count
13 + audit.hero_spell_count
14 + audit.hero_aura_count;
15
16 if has_errors {
17 output::error(&format!(
18 "{} [{}] ({} IDs, {} errors)",
19 audit.display_name,
20 audit.spec_id,
21 total_ids,
22 audit.errors.len(),
23 ));
24 } else {
25 output::success(&format!(
26 "{} [{}] ({} IDs)",
27 audit.display_name, audit.spec_id, total_ids,
28 ));
29 }
30
31 for err in &audit.errors {
32 print_issue(err);
33 }
34
35 for warn in &audit.warnings {
36 output::warning(&format!(" {warn}"));
38 }
39
40 if !has_errors && !has_warnings {
41 output::kv("Status", "all valid");
42 }
43
44 output::blank();
45}
46
47fn print_issue(issue: &AuditIssue) {
48 output::error(&format!(
49 " {:<12} {:<40} ({:>7}) {}",
50 issue.category, issue.name, issue.id, issue.message,
51 ));
52}
53
54pub(super) fn print_summary(
55 total_errors: usize,
56 total_warnings: usize,
57 specs_with_errors: usize,
58 total_specs: usize,
59) {
60 output::separator();
61 output::blank();
62
63 if total_errors == 0 {
64 output::success(&format!("{total_specs} specs audited, all IDs valid"));
65 } else {
66 output::error(&format!(
67 "{total_errors} errors in {specs_with_errors}/{total_specs} specs",
68 ));
69 }
70
71 if total_warnings > 0 {
72 output::warning(&format!("{total_warnings} warnings (stub id=0)"));
73 }
74}