(
rows: &[AllRow],
kind: AgentReportKind,
shared: &SharedArgs,
detected_agents: &[&'static str],
)
| 65 | } |
| 66 | |
| 67 | pub(super) fn print_table( |
| 68 | rows: &[AllRow], |
| 69 | kind: AgentReportKind, |
| 70 | shared: &SharedArgs, |
| 71 | detected_agents: &[&'static str], |
| 72 | ) -> Result<()> { |
| 73 | print_box_title(&all_report_title(kind, rows, detected_agents), shared); |
| 74 | if rows.is_empty() { |
| 75 | eprintln!("No usage data found."); |
| 76 | return Ok(()); |
| 77 | } |
| 78 | let terminal_width = crate::terminal_width(); |
| 79 | let is_tty = std::io::stdout().is_terminal(); |
| 80 | let compact = should_use_compact_layout( |
| 81 | shared, |
| 82 | is_tty, |
| 83 | terminal_width, |
| 84 | crate::USAGE_COMPACT_WIDTH_THRESHOLD, |
| 85 | ); |
| 86 | let (headers, aligns) = all_table_columns(kind, compact, shared.no_cost); |
| 87 | let mut table = SimpleTable::new(headers, aligns, crate::terminal_style(shared)) |
| 88 | .with_terminal_width(terminal_width) |
| 89 | .with_date_compaction(true); |
| 90 | |
| 91 | for row in rows { |
| 92 | table.push(all_table_row(row, compact, false, shared.no_cost)); |
| 93 | if let Some(agent_breakdowns) = row.agent_breakdowns.as_ref() { |
| 94 | for breakdown in agent_breakdowns { |
| 95 | table.push(all_table_row(breakdown, compact, true, shared.no_cost)); |
| 96 | if shared.breakdown && !breakdown.model_breakdowns.is_empty() { |
| 97 | push_model_breakdown_rows( |
| 98 | &mut table, |
| 99 | &breakdown.model_breakdowns, |
| 100 | compact, |
| 101 | shared, |
| 102 | ); |
| 103 | } |
| 104 | } |
| 105 | } else if shared.breakdown && !row.model_breakdowns.is_empty() { |
| 106 | push_model_breakdown_rows(&mut table, &row.model_breakdowns, compact, shared); |
| 107 | } |
| 108 | } |
| 109 | table.separator(); |
| 110 | let totals = totals_json(rows); |
| 111 | let table_total_tokens = rows.iter().map(table_total_tokens).sum::<u64>(); |
| 112 | if compact { |
| 113 | let mut total_row = vec![ |
| 114 | color(shared, "Total", Color::Yellow), |
| 115 | String::new(), |
| 116 | String::new(), |
| 117 | color( |
| 118 | shared, |
| 119 | format_number(crate::json_value_u64(totals.get("inputTokens"))), |
| 120 | Color::Yellow, |
| 121 | ), |
| 122 | color( |
| 123 | shared, |
| 124 | format_number(crate::json_value_u64(totals.get("outputTokens"))), |
no test coverage detected