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

Function print_table_from_groups

rust/crates/ccusage/src/adapter/codex/report.rs:200–309  ·  view source on GitHub ↗
(
    groups: &BTreeMap<String, CodexGroup>,
    kind: AgentReportKind,
    pricing: &PricingMap,
    speed: CodexSpeed,
    shared: &SharedArgs,
)

Source from the content-addressed store, hash-verified

198}
199
200pub(super) fn print_table_from_groups(
201 groups: &BTreeMap<String, CodexGroup>,
202 kind: AgentReportKind,
203 pricing: &PricingMap,
204 speed: CodexSpeed,
205 shared: &SharedArgs,
206) -> Result<()> {
207 if groups.is_empty() {
208 eprintln!("No Codex usage data found.");
209 return Ok(());
210 }
211 let first_column = match kind {
212 AgentReportKind::Daily => "Date",
213 AgentReportKind::Weekly => "Week",
214 AgentReportKind::Monthly => "Month",
215 AgentReportKind::Session => "Session",
216 };
217 print_box_title(
218 &format!(
219 "Codex Token Usage Report - {}",
220 match kind {
221 AgentReportKind::Daily => "Daily",
222 AgentReportKind::Weekly => "Weekly",
223 AgentReportKind::Monthly => "Monthly",
224 AgentReportKind::Session => "Session",
225 }
226 ),
227 shared,
228 );
229 let mut headers = vec![
230 first_column,
231 "Models",
232 "Input",
233 "Output",
234 "Reasoning",
235 "Cache Read",
236 "Total Tokens",
237 "Cost (USD)",
238 ];
239 let mut aligns = vec![
240 Align::Left,
241 Align::Left,
242 Align::Right,
243 Align::Right,
244 Align::Right,
245 Align::Right,
246 Align::Right,
247 Align::Right,
248 ];
249 if shared.no_cost {
250 headers.pop();
251 aligns.pop();
252 }
253 let mut table = SimpleTable::new(headers, aligns, crate::terminal_style(shared))
254 .with_terminal_width(crate::terminal_width())
255 .with_date_compaction(true);
256 let mut total_input = 0;
257 let mut total_cached = 0;

Callers 1

runFunction · 0.85

Calls 13

terminal_styleFunction · 0.85
terminal_widthFunction · 0.85
non_cached_input_tokensFunction · 0.85
calculate_group_costFunction · 0.85
format_models_multilineFunction · 0.85
with_date_compactionMethod · 0.80
with_terminal_widthMethod · 0.80
pushMethod · 0.80
separatorMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected