mint_cli/visuals/
mod.rs

1mod formatters;
2
3use crate::commands::stats::BuildStats;
4use comfy_table::{Attribute, Cell, ContentArrangement, Table};
5use formatters::{format_address_range, format_bytes, format_duration, format_efficiency};
6
7pub fn print_summary(stats: &BuildStats) {
8    println!(
9        "✓ Built {} blocks in {} ({:.1}% efficiency)",
10        stats.blocks_processed,
11        format_duration(stats.total_duration),
12        stats.space_efficiency()
13    );
14}
15
16pub fn print_detailed(stats: &BuildStats) {
17    let mut summary_table = Table::new();
18    summary_table
19        .set_content_arrangement(ContentArrangement::Dynamic)
20        .set_header(vec![
21            Cell::new("Build Summary")
22                .add_attribute(Attribute::Bold)
23                .set_alignment(comfy_table::CellAlignment::Left),
24            Cell::new(""),
25        ]);
26
27    summary_table.add_row(vec!["Build Time", &format_duration(stats.total_duration)]);
28    summary_table.add_row(vec![
29        "Blocks Processed",
30        &format!("{}", stats.blocks_processed),
31    ]);
32    summary_table.add_row(vec![
33        "Total Allocated",
34        &format_bytes(stats.total_allocated),
35    ]);
36    summary_table.add_row(vec!["Total Used", &format_bytes(stats.total_used)]);
37    summary_table.add_row(vec![
38        "Space Efficiency",
39        &format!("{:.1}%", stats.space_efficiency()),
40    ]);
41
42    println!("{summary_table}\n");
43
44    let mut detail_table = Table::new();
45    detail_table
46        .set_content_arrangement(ContentArrangement::Dynamic)
47        .set_header(vec![
48            Cell::new("Block").add_attribute(Attribute::Bold),
49            Cell::new("Address Range").add_attribute(Attribute::Bold),
50            Cell::new("Used/Alloc").add_attribute(Attribute::Bold),
51            Cell::new("Efficiency").add_attribute(Attribute::Bold),
52            Cell::new("CRC Value").add_attribute(Attribute::Bold),
53        ]);
54
55    for block in &stats.block_stats {
56        detail_table.add_row(vec![
57            Cell::new(&block.name),
58            Cell::new(format_address_range(
59                block.start_address,
60                block.allocated_size,
61            )),
62            Cell::new(format!(
63                "{}/{}",
64                format_bytes(block.used_size as usize),
65                format_bytes(block.allocated_size as usize)
66            )),
67            Cell::new(format_efficiency(block.used_size, block.allocated_size)),
68            Cell::new(format!("0x{:08X}", block.crc_value)),
69        ]);
70    }
71
72    println!("{detail_table}");
73}