(
title: &str,
first_column: &str,
rows: &[UsageSummary],
shared: &SharedArgs,
group_projects: bool,
project_aliases: Option<&str>,
)
| 143 | } |
| 144 | |
| 145 | pub(crate) fn print_usage_table( |
| 146 | title: &str, |
| 147 | first_column: &str, |
| 148 | rows: &[UsageSummary], |
| 149 | shared: &SharedArgs, |
| 150 | group_projects: bool, |
| 151 | project_aliases: Option<&str>, |
| 152 | ) -> Result<()> { |
| 153 | if rows.is_empty() { |
| 154 | eprintln!("{}", empty_usage_table_message()); |
| 155 | return Ok(()); |
| 156 | } |
| 157 | let terminal_width = terminal_width(); |
| 158 | let is_tty = io::stdout().is_terminal(); |
| 159 | let compact = should_use_compact_layout( |
| 160 | shared, |
| 161 | is_tty, |
| 162 | terminal_width, |
| 163 | USAGE_COMPACT_WIDTH_THRESHOLD, |
| 164 | ); |
| 165 | let include_last_activity = rows.iter().any(|row| row.last_activity.is_some()); |
| 166 | print_box_title(title, shared); |
| 167 | let mut headers = if compact { |
| 168 | vec![first_column, "Models", "Input", "Output", "Cost (USD)"] |
| 169 | } else { |
| 170 | vec![ |
| 171 | first_column, |
| 172 | "Models", |
| 173 | "Input", |
| 174 | "Output", |
| 175 | "Cache Create", |
| 176 | "Cache Read", |
| 177 | "Total Tokens", |
| 178 | "Cost (USD)", |
| 179 | ] |
| 180 | }; |
| 181 | let mut aligns = if compact { |
| 182 | vec![ |
| 183 | Align::Left, |
| 184 | Align::Left, |
| 185 | Align::Right, |
| 186 | Align::Right, |
| 187 | Align::Right, |
| 188 | ] |
| 189 | } else { |
| 190 | vec![ |
| 191 | Align::Left, |
| 192 | Align::Left, |
| 193 | Align::Right, |
| 194 | Align::Right, |
| 195 | Align::Right, |
| 196 | Align::Right, |
| 197 | Align::Right, |
| 198 | Align::Right, |
| 199 | ] |
| 200 | }; |
| 201 | if shared.no_cost { |
| 202 | headers.pop(); |
no test coverage detected