report_demo/
report_demo.rs1use runemark::{
2 ColorMode, Console, DetailLevel, DiffBlock, ErrorBlock, FileAction, FileChange, Finding,
3 FindingGroup, Location, Metric, NextStep, Report, ScopeNote, Verdict,
4};
5
6fn main() {
7 let console = Console::stdout(ColorMode::Auto);
8
9 println!("=== 1. Verdict & Status ===");
10 println!(
11 "{}",
12 Verdict::Passed.render(console, "Configuration validated cleanly")
13 );
14 println!(
15 "{}",
16 Verdict::Warning.render(console, "3 non-critical findings detected")
17 );
18 println!(
19 "{}",
20 Verdict::Failed.render(console, "Build failed: 2 errors")
21 );
22 println!();
23
24 println!("=== 2. Error / Prerequisite Block ===");
25 let err_block = ErrorBlock::new("Required toolchain is unavailable")
26 .with_explanation("The configured version is not installed.")
27 .with_remedy("Install the required toolchain:")
28 .add_command("toolchain install stable");
29 print!("{}", err_block.render(console));
30
31 println!("=== 3. Decision-Oriented Report (Compact) ===");
32 let report = Report::new("Site audit v1.2.0", Verdict::Warning)
33 .add_scope_note(ScopeNote::new(
34 "Scope warnings",
35 vec![
36 "Git history partial".to_string(),
37 "1 file skipped".to_string(),
38 ],
39 ))
40 .add_metric(Metric::new("Errors", "0"))
41 .add_metric(Metric::new("Warnings", "4").with_trend(runemark::Trend::Negative, "+2"))
42 .add_metric(Metric::new("Score", "94/100").with_trend(runemark::Trend::Positive, "+5%"))
43 .add_group(
44 FindingGroup::new("Accessibility Violations")
45 .add_finding(
46 Finding::new(runemark::Tone::Warning, "Image missing alt attribute")
47 .with_rule_id("a11y/img-alt")
48 .with_badge(runemark::Badge::quick_win())
49 .with_confidence(runemark::Confidence::High)
50 .with_location(Location::file_line_col("src/pages/index.astro", 42, 10))
51 .with_remedy("Add alt=\"...\" description to <img> tag"),
52 )
53 .add_finding(
54 Finding::new(runemark::Tone::Warning, "Low contrast ratio on hero button")
55 .with_rule_id("a11y/contrast")
56 .with_location(Location::file_line("src/components/Hero.astro", 18)),
57 ),
58 )
59 .add_next_step(
60 NextStep::new("Run auto-fixer for formatting issues").with_command("audit --fix"),
61 );
62
63 print!("{}", report.render(console));
64
65 println!("=== 4. Detailed Report View ===");
66 let detailed_report = report.with_detail_level(DetailLevel::Detailed);
67 print!("{}", detailed_report.render(console));
68
69 println!("=== 5. Generator Diff View ===");
70 let diff = DiffBlock::new()
71 .add_change(
72 FileChange::new(FileAction::Added, "src/components/Footer.astro").with_delta("+1.2 kB"),
73 )
74 .add_change(FileChange::new(
75 FileAction::Modified,
76 "src/layouts/Layout.astro",
77 ))
78 .add_change(FileChange::new(
79 FileAction::Deleted,
80 "src/legacy/Footer.jsx",
81 ));
82 print!("{}", diff.render(console));
83}