use super::super::BackupPruneReport;
use ic_host_text::table::{self, Alignment, Options};
pub(super) fn render_prune_report(report: &BackupPruneReport) -> String {
let summary_rows = [[
if report.dry_run { "dry-run" } else { "execute" }.to_string(),
report.scanned.to_string(),
report.selected.to_string(),
report.pruned.to_string(),
]];
let entry_rows = report
.entries
.iter()
.map(|entry| {
[
entry.index.to_string(),
entry.dir.display().to_string(),
entry.backup_id.clone(),
entry.status.label().to_string(),
entry.action.label().to_string(),
entry.detail.clone().unwrap_or_default(),
]
})
.collect::<Vec<_>>();
[
table::render(
&["MODE", "SCANNED", "SELECTED", "PRUNED"],
&summary_rows,
&[Alignment::Left; 4],
Options {
column_gap: 3,
header_separator: true,
},
),
String::new(),
table::render(
&["#", "DIR", "BACKUP_ID", "STATUS", "ACTION", "DETAIL"],
&entry_rows,
&[
Alignment::Right,
Alignment::Left,
Alignment::Left,
Alignment::Left,
Alignment::Left,
Alignment::Left,
],
Options {
column_gap: 3,
header_separator: true,
},
),
]
.join("\n")
}