MCPcopy Create free account
hub / github.com/evilsocket/cake / push_layer_bar

Function push_layer_bar

cake-cli/src/chat.rs:730–766  ·  view source on GitHub ↗
(
    lines: &mut Vec<Line<'static>>,
    name: &str,
    count: usize,
    total: usize,
    bar_max_width: usize,
    color: Color,
)

Source from the content-addressed store, hash-verified

728}
729
730fn push_layer_bar(
731 lines: &mut Vec<Line<'static>>,
732 name: &str,
733 count: usize,
734 total: usize,
735 bar_max_width: usize,
736 color: Color,
737) {
738 let pct = if total > 0 {
739 count as f64 / total as f64
740 } else {
741 0.0
742 };
743 let bar_filled = (pct * bar_max_width as f64) as usize;
744 let bar_filled = if count > 0 { bar_filled.max(1) } else { 0 };
745 let bar_empty = bar_max_width.saturating_sub(bar_filled);
746
747 lines.push(Line::from(vec![
748 Span::styled(
749 format!(" {:>12} ", name),
750 Style::default().fg(Color::DarkGray),
751 ),
752 Span::styled(
753 "\u{2588}".repeat(bar_filled),
754 Style::default().fg(color),
755 ),
756 Span::styled(
757 "\u{2591}".repeat(bar_empty),
758 Style::default().fg(Color::DarkGray),
759 ),
760 Span::raw(" "),
761 Span::styled(
762 format!("{} ({:.0}%)", count, pct * 100.0),
763 Style::default().fg(Color::White),
764 ),
765 ]));
766}
767
768// ── SSE streaming ──────────────────────────────────────────────────────────
769

Callers 1

build_cluster_linesFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected