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

Function print_usage_table

rust/crates/ccusage/src/output.rs:145–332  ·  view source on GitHub ↗
(
    title: &str,
    first_column: &str,
    rows: &[UsageSummary],
    shared: &SharedArgs,
    group_projects: bool,
    project_aliases: Option<&str>,
)

Source from the content-addressed store, hash-verified

143}
144
145pub(crate) fn print_usage_table(
146 title: &str,
147 first_column: &str,
148 rows: &[UsageSummary],
149 shared: &SharedArgs,
150 group_projects: bool,
151 project_aliases: Option<&str>,
152) -> Result<()> {
153 if rows.is_empty() {
154 eprintln!("{}", empty_usage_table_message());
155 return Ok(());
156 }
157 let terminal_width = terminal_width();
158 let is_tty = io::stdout().is_terminal();
159 let compact = should_use_compact_layout(
160 shared,
161 is_tty,
162 terminal_width,
163 USAGE_COMPACT_WIDTH_THRESHOLD,
164 );
165 let include_last_activity = rows.iter().any(|row| row.last_activity.is_some());
166 print_box_title(title, shared);
167 let mut headers = if compact {
168 vec![first_column, "Models", "Input", "Output", "Cost (USD)"]
169 } else {
170 vec![
171 first_column,
172 "Models",
173 "Input",
174 "Output",
175 "Cache Create",
176 "Cache Read",
177 "Total Tokens",
178 "Cost (USD)",
179 ]
180 };
181 let mut aligns = if compact {
182 vec![
183 Align::Left,
184 Align::Left,
185 Align::Right,
186 Align::Right,
187 Align::Right,
188 ]
189 } else {
190 vec![
191 Align::Left,
192 Align::Left,
193 Align::Right,
194 Align::Right,
195 Align::Right,
196 Align::Right,
197 Align::Right,
198 Align::Right,
199 ]
200 };
201 if shared.no_cost {
202 headers.pop();

Callers 14

run_dailyFunction · 0.85
run_bucketFunction · 0.85
run_weeklyFunction · 0.85
run_sessionFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 15

terminal_widthFunction · 0.85
terminal_styleFunction · 0.85
parse_project_aliasesFunction · 0.85
project_header_rowFunction · 0.85
format_project_nameFunction · 0.85
format_models_multilineFunction · 0.85
truncate_rfc3339_to_dateFunction · 0.85
push_breakdown_rowsFunction · 0.85
anyMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected