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_efficiency};
6
7pub fn print_summary(stats: &BuildStats) {
8    println!(
9        "✓ Built {} blocks in {}ms ({:.1}% efficiency)",
10        stats.blocks_processed,
11        stats.total_duration.as_millis(),
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![
28        "Build Time",
29        &format!("{}ms", stats.total_duration.as_millis()),
30    ]);
31    summary_table.add_row(vec![
32        "Blocks Processed",
33        &format!("{}", stats.blocks_processed),
34    ]);
35    summary_table.add_row(vec![
36        "Total Allocated",
37        &format_bytes(stats.total_allocated),
38    ]);
39    summary_table.add_row(vec!["Total Used", &format_bytes(stats.total_used)]);
40    summary_table.add_row(vec![
41        "Space Efficiency",
42        &format!("{:.1}%", stats.space_efficiency()),
43    ]);
44
45    println!("{summary_table}\n");
46
47    let mut detail_table = Table::new();
48    detail_table
49        .set_content_arrangement(ContentArrangement::Dynamic)
50        .set_header(vec![
51            Cell::new("Block").add_attribute(Attribute::Bold),
52            Cell::new("Address Range").add_attribute(Attribute::Bold),
53            Cell::new("Used/Alloc").add_attribute(Attribute::Bold),
54            Cell::new("Efficiency").add_attribute(Attribute::Bold),
55            Cell::new("CRC Value").add_attribute(Attribute::Bold),
56        ]);
57
58    for block in &stats.block_stats {
59        detail_table.add_row(vec![
60            Cell::new(&block.name),
61            Cell::new(format_address_range(
62                block.start_address,
63                block.allocated_size,
64            )),
65            Cell::new(format!(
66                "{}/{}",
67                format_bytes(block.used_size as usize),
68                format_bytes(block.allocated_size as usize)
69            )),
70            Cell::new(format_efficiency(block.used_size, block.allocated_size)),
71            Cell::new(format!("0x{:08X}", block.crc_value)),
72        ]);
73    }
74
75    println!("{detail_table}");
76}