| 141 | /// Prints the status output as a compact bordered table. |
| 142 | #[allow(clippy::too_many_arguments)] |
| 143 | pub fn print_status_table( |
| 144 | stats: &GraphStats, |
| 145 | tokens_saved: u64, |
| 146 | global_tokens_saved: Option<u64>, |
| 147 | worldwide: Option<u64>, |
| 148 | country_flags: &[String], |
| 149 | branch_info: Option<&BranchInfo>, |
| 150 | cost_info: Option<&CostRow>, |
| 151 | details: bool, |
| 152 | ) { |
| 153 | let num_cols = 3; |
| 154 | debug_assert!( |
| 155 | stats.file_count > 0 || stats.node_count == 0, |
| 156 | "print_status_table: node_count should be 0 when file_count is 0" |
| 157 | ); |
| 158 | debug_assert!( |
| 159 | stats.node_count >= stats.file_count || stats.file_count == 0, |
| 160 | "print_status_table: node_count should be >= file_count" |
| 161 | ); |
| 162 | |
| 163 | let mut sorted_kinds: Vec<_> = stats.nodes_by_kind.iter().collect(); |
| 164 | sorted_kinds.sort_by_key(|(k, _)| (*k).clone()); |
| 165 | let num_kind_rows = sorted_kinds.len().div_ceil(num_cols); |
| 166 | |
| 167 | let cell_width = compute_cell_width(&sorted_kinds); |
| 168 | let inner_width = cell_width * num_cols + (num_cols - 1); |
| 169 | |
| 170 | println!("{}", table_separator('╭', '─', '╮', cell_width, num_cols)); |
| 171 | print_version_flags_row(country_flags, inner_width); |
| 172 | print_tokens_row(tokens_saved, global_tokens_saved, worldwide, inner_width); |
| 173 | if let Some(ci) = cost_info { |
| 174 | print_cost_row(ci, inner_width); |
| 175 | } |
| 176 | print_sync_row( |
| 177 | stats.last_sync_at, |
| 178 | stats.last_full_sync_at, |
| 179 | stats.last_sync_duration_ms, |
| 180 | inner_width, |
| 181 | ); |
| 182 | if let Some(bi) = branch_info { |
| 183 | print_branch_row(bi, inner_width); |
| 184 | } |
| 185 | println!("{}", table_separator('├', '┬', '┤', cell_width, num_cols)); |
| 186 | |
| 187 | let stats_rows = build_stats_rows(stats, num_cols); |
| 188 | print_table_rows(&stats_rows, cell_width, num_cols); |
| 189 | |
| 190 | if details && !sorted_kinds.is_empty() { |
| 191 | println!("{}", table_separator('├', '┼', '┤', cell_width, num_cols)); |
| 192 | print_kind_rows(&sorted_kinds, num_kind_rows, num_cols, cell_width); |
| 193 | } |
| 194 | |
| 195 | println!("{}", table_separator('╰', '┴', '╯', cell_width, num_cols)); |
| 196 | } |
| 197 | |
| 198 | /// Maximum cell width — caps total table width at 100 columns. |
| 199 | const MAX_CELL_WIDTH: usize = 32; |