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

Function push_model_breakdown_rows

rust/crates/ccusage/src/adapter/all/report.rs:325–370  ·  view source on GitHub ↗
(
    table: &mut SimpleTable,
    breakdowns: &[ModelBreakdown],
    compact: bool,
    shared: &SharedArgs,
)

Source from the content-addressed store, hash-verified

323}
324
325fn push_model_breakdown_rows(
326 table: &mut SimpleTable,
327 breakdowns: &[ModelBreakdown],
328 compact: bool,
329 shared: &SharedArgs,
330) {
331 for b in breakdowns {
332 let total =
333 b.input_tokens + b.output_tokens + b.cache_creation_tokens + b.cache_read_tokens;
334 let model = color(
335 shared,
336 format!("- {}", short_model_name(&b.model_name)),
337 Color::Grey,
338 );
339 if compact {
340 let mut row = vec![
341 String::new(),
342 String::new(),
343 model,
344 color(shared, format_number(b.input_tokens), Color::Grey),
345 color(shared, format_number(b.output_tokens), Color::Grey),
346 color(shared, format_currency(b.cost), Color::Grey),
347 ];
348 if shared.no_cost {
349 row.pop();
350 }
351 table.push(row);
352 } else {
353 let mut row = vec![
354 String::new(),
355 String::new(),
356 model,
357 color(shared, format_number(b.input_tokens), Color::Grey),
358 color(shared, format_number(b.output_tokens), Color::Grey),
359 color(shared, format_number(b.cache_creation_tokens), Color::Grey),
360 color(shared, format_number(b.cache_read_tokens), Color::Grey),
361 color(shared, format_number(total), Color::Grey),
362 color(shared, format_currency(b.cost), Color::Grey),
363 ];
364 if shared.no_cost {
365 row.pop();
366 }
367 table.push(row);
368 }
369 }
370}
371
372pub(super) fn all_table_columns(
373 kind: AgentReportKind,

Callers 1

print_tableFunction · 0.85

Calls 2

pushMethod · 0.80
colorFunction · 0.50

Tested by

no test coverage detected