callisto_cli/render/
mod.rs1use std::io;
2
3use callisto_model::{
4 ComposePrBodyReport, InitReport, PublishPlan, SnapshotReport, StatusReport, TagReport,
5 ValidateReport, VersionReport,
6};
7
8pub mod attribution;
9pub mod diff;
10
11pub fn render_diagnostics<W: io::Write>(
12 diagnostics: &[callisto_model::Diagnostic],
13 w: &mut W,
14) -> io::Result<()> {
15 if !diagnostics.is_empty() {
16 writeln!(w, "\nDiagnostics:")?;
17 for d in diagnostics {
18 writeln!(w, " [{:?}] {}", d.severity, d.message)?;
19 }
20 }
21 Ok(())
22}
23
24pub fn render_status<W: io::Write>(report: &StatusReport, w: &mut W) -> io::Result<()> {
25 writeln!(w, "Status (schema v{}):", report.schema_version)?;
26 for pkg in &report.packages {
27 writeln!(
28 w,
29 " {} {} (pending: {:?})",
30 pkg.package.display_name(),
31 pkg.current_version.raw(),
32 pkg.pending_severity
33 )?;
34 }
35 render_diagnostics(&report.diagnostics, w)
36}
37
38pub fn render_version<W: io::Write>(report: &VersionReport, w: &mut W) -> io::Result<()> {
39 writeln!(w, "Version Plan (schema v{}):", report.schema_version)?;
40 for bump in &report.bumps {
41 writeln!(
42 w,
43 " {} {} → {}",
44 bump.package.display_name(),
45 bump.from.raw(),
46 bump.to.raw()
47 )?;
48 }
49 render_diagnostics(&report.diagnostics, w)
50}
51
52pub fn render_publish<W: io::Write>(report: &PublishPlan, w: &mut W) -> io::Result<()> {
53 writeln!(w, "Publish Plan (schema v{}):", report.schema_version)?;
54 for rel in &report.releases {
55 writeln!(w, " Tag: {} (sha: {})", rel.tag_name, rel.sha.as_str())?;
56 }
57 Ok(())
58}
59
60pub fn render_snapshot<W: io::Write>(report: &SnapshotReport, w: &mut W) -> io::Result<()> {
61 writeln!(w, "Snapshot Tag: {}", report.snapshot_tag)?;
62 for bump in &report.bumps {
63 writeln!(
64 w,
65 " {} {} → {}",
66 bump.package.display_name(),
67 bump.from.raw(),
68 bump.to.raw()
69 )?;
70 }
71 Ok(())
72}
73
74pub fn render_validate<W: io::Write>(report: &ValidateReport, w: &mut W) -> io::Result<()> {
75 if report.valid {
76 writeln!(w, "Validation passed.")?;
77 } else {
78 writeln!(w, "Validation failed with diagnostics:")?;
79 for diag in &report.diagnostics {
80 writeln!(w, " [{:?}] {}", diag.severity, diag.message)?;
81 }
82 }
83 Ok(())
84}
85
86pub fn render_tag<W: io::Write>(report: &TagReport, w: &mut W) -> io::Result<()> {
87 writeln!(w, "Created Tags:")?;
88 for tag in &report.created_tags {
89 writeln!(w, " {} ({})", tag.tag_name, tag.sha.as_str())?;
90 }
91 Ok(())
92}
93
94pub fn render_compose_pr_body<W: io::Write>(
95 report: &ComposePrBodyReport,
96 w: &mut W,
97) -> io::Result<()> {
98 write!(w, "{}", report.pr_body)?;
99 Ok(())
100}
101
102pub fn render_init<W: io::Write>(report: &InitReport, w: &mut W) -> io::Result<()> {
103 writeln!(
104 w,
105 "Initialized callisto configuration at {}",
106 report.config_path.display()
107 )?;
108 Ok(())
109}