cfspeedtest 2.0.3

Unofficial CLI for speed.cloudflare.com
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::io::stdout;
use std::io::Write;

pub fn print_progress(name: &str, curr: u32, max: u32) {
    const BAR_LEN: u32 = 30;
    let progress_line = ((curr as f32 / max as f32) * BAR_LEN as f32) as u32;
    let remaining_line = BAR_LEN - progress_line;
    print!(
        "\r{:<15} [{}{}]",
        name,
        (0..progress_line).map(|_| "=").collect::<String>(),
        (0..remaining_line).map(|_| "-").collect::<String>(),
    );
    stdout().flush().expect("error printing progress bar");
}