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

Function table_line

rust/crates/ccusage-terminal/src/table.rs:341–356  ·  view source on GitHub ↗
(cells: &[String], aligns: &[Align], widths: &[usize])

Source from the content-addressed store, hash-verified

339}
340
341fn table_line(cells: &[String], aligns: &[Align], widths: &[usize]) -> String {
342 let mut line = String::from("│");
343 for (index, width) in widths.iter().enumerate() {
344 let cell = cells.get(index).map(String::as_str).unwrap_or("");
345 let align = if index == 0 && cell.starts_with("(assuming ") {
346 Align::Right
347 } else {
348 aligns.get(index).copied().unwrap_or(Align::Left)
349 };
350 line.push(' ');
351 line.push_str(&pad_cell(cell, width.saturating_sub(2), align));
352 line.push(' ');
353 line.push('│');
354 }
355 line
356}
357
358fn pad_cell(cell: &str, width: usize, align: Align) -> String {
359 let visible = visible_width(cell);

Callers 1

render_linesMethod · 0.85

Calls 2

pad_cellFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected