(args: AgentCommandArgs)
| 13 | pub(crate) use report::{report_from_rows, summarize_entries}; |
| 14 | |
| 15 | pub(crate) fn run(args: AgentCommandArgs) -> Result<()> { |
| 16 | let shared = args.shared; |
| 17 | let pricing = PricingMap::load_with_overrides( |
| 18 | shared.offline, |
| 19 | crate::log_level() != Some(0), |
| 20 | shared.pricing_overrides.iter(), |
| 21 | ); |
| 22 | let mut entries = load_entries(&shared, &pricing)?; |
| 23 | filter_loaded_entries_by_date(&mut entries, &shared); |
| 24 | let mut rows = summarize_entries(&entries, args.kind)?; |
| 25 | sort_summaries(&mut rows, &shared.order, |row| { |
| 26 | crate::adapter::opencode::summary_period(row) |
| 27 | }); |
| 28 | if wants_json(&shared) { |
| 29 | return print_json_or_jq( |
| 30 | report_from_rows(&rows, args.kind), |
| 31 | shared.jq.as_deref(), |
| 32 | shared.no_cost, |
| 33 | ); |
| 34 | } |
| 35 | if rows.is_empty() { |
| 36 | eprintln!("{}", empty_usage_message()); |
| 37 | return Ok(()); |
| 38 | } |
| 39 | print_usage_table( |
| 40 | "GitHub Copilot CLI Token Usage Report", |
| 41 | crate::adapter::opencode::first_column(args.kind), |
| 42 | &rows, |
| 43 | &shared, |
| 44 | false, |
| 45 | None, |
| 46 | )?; |
| 47 | Ok(()) |
| 48 | } |
| 49 | |
| 50 | fn empty_usage_message() -> &'static str { |
| 51 | "No GitHub Copilot CLI usage data found.\nEnable Copilot OpenTelemetry file export before starting or resuming Copilot sessions.\nSee https://ccusage.com/guide/copilot/#data-source" |
nothing calls this directly
no test coverage detected