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

Function run

rust/crates/ccusage/src/adapter/copilot/mod.rs:15–48  ·  view source on GitHub ↗
(args: AgentCommandArgs)

Source from the content-addressed store, hash-verified

13pub(crate) use report::{report_from_rows, summarize_entries};
14
15pub(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
50fn 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"

Callers

nothing calls this directly

Calls 11

log_levelFunction · 0.85
sort_summariesFunction · 0.85
wants_jsonFunction · 0.85
print_json_or_jqFunction · 0.85
print_usage_tableFunction · 0.85
load_entriesFunction · 0.70
summarize_entriesFunction · 0.70
report_from_rowsFunction · 0.70
summary_periodFunction · 0.50
first_columnFunction · 0.50

Tested by

no test coverage detected