MCPcopy Create free account
hub / github.com/ccusage/ccusage / all_table_row

Function all_table_row

rust/crates/ccusage/src/adapter/all/report.rs:262–316  ·  view source on GitHub ↗
(
    row: &AllRow,
    compact: bool,
    breakdown: bool,
    no_cost: bool,
)

Source from the content-addressed store, hash-verified

260}
261
262pub(super) fn all_table_row(
263 row: &AllRow,
264 compact: bool,
265 breakdown: bool,
266 no_cost: bool,
267) -> Vec<String> {
268 let period = if breakdown {
269 String::new()
270 } else {
271 row.period.clone()
272 };
273 let agent = if breakdown {
274 format!("- {}", agent_label(row.agent))
275 } else if row.agent_breakdowns.is_some() {
276 "All".to_string()
277 } else {
278 agent_label(row.agent).to_string()
279 };
280 let models = if row.agent_breakdowns.is_some() {
281 String::new()
282 } else {
283 format_models_multiline(&row.models_used)
284 };
285
286 if compact {
287 let mut values = vec![
288 period,
289 agent,
290 models,
291 format_number(row.input_tokens),
292 format_number(row.output_tokens),
293 format_currency(row.total_cost),
294 ];
295 if no_cost {
296 values.pop();
297 }
298 return values;
299 }
300
301 let mut values = vec![
302 period,
303 agent,
304 models,
305 format_number(row.input_tokens),
306 format_number(row.output_tokens),
307 format_number(row.cache_creation_tokens),
308 format_number(row.cache_read_tokens),
309 format_number(table_total_tokens(row)),
310 format_currency(row.total_cost),
311 ];
312 if no_cost {
313 values.pop();
314 }
315 values
316}
317
318fn table_total_tokens(row: &AllRow) -> u64 {
319 row.input_tokens

Calls 2

format_models_multilineFunction · 0.85
agent_labelFunction · 0.70