Skip to main content

bar_line

Function bar_line 

Source
pub fn bar_line(message: &str, step: u32, total: u32) -> String
Expand description

Renders one determinate progress-bar line for step of total.

step and total are clamped so the bar always stays within [0, 100]%.

use limitless_cli::modules::progress::{BAR_WIDTH, bar_line};

let line = bar_line("Running diagnostics...", 8, 20);
assert!(line.ends_with("] 40%"));
let filled = line.matches('█').count();
assert_eq!(filled, 8);
assert_eq!(filled + line.matches('░').count(), BAR_WIDTH);
assert!(bar_line("Running diagnostics...", 99, 20).ends_with("100%"));