| 106 | } |
| 107 | |
| 108 | pub fn print_status_header( |
| 109 | stats: &GraphStats, |
| 110 | tokens_saved: u64, |
| 111 | global_tokens_saved: Option<u64>, |
| 112 | worldwide: Option<u64>, |
| 113 | country_flags: &[String], |
| 114 | branch_info: Option<&BranchInfo>, |
| 115 | cost_info: Option<&CostRow>, |
| 116 | ) { |
| 117 | let num_cols = 3; |
| 118 | let mut sorted_kinds: Vec<_> = stats.nodes_by_kind.iter().collect(); |
| 119 | sorted_kinds.sort_by_key(|(k, _)| (*k).clone()); |
| 120 | let cell_width = compute_cell_width(&sorted_kinds); |
| 121 | let inner_width = cell_width * num_cols + (num_cols - 1); |
| 122 | |
| 123 | println!("{}", table_separator('╭', '─', '╮', cell_width, num_cols)); |
| 124 | print_version_flags_row(country_flags, inner_width); |
| 125 | print_tokens_row(tokens_saved, global_tokens_saved, worldwide, inner_width); |
| 126 | if let Some(ci) = cost_info { |
| 127 | print_cost_row(ci, inner_width); |
| 128 | } |
| 129 | print_sync_row( |
| 130 | stats.last_sync_at, |
| 131 | stats.last_full_sync_at, |
| 132 | stats.last_sync_duration_ms, |
| 133 | inner_width, |
| 134 | ); |
| 135 | if let Some(bi) = branch_info { |
| 136 | print_branch_row(bi, inner_width); |
| 137 | } |
| 138 | println!("{}", table_separator('╰', '─', '╯', cell_width, num_cols)); |
| 139 | } |
| 140 | |
| 141 | /// Prints the status output as a compact bordered table. |
| 142 | #[allow(clippy::too_many_arguments)] |