#progress #progress-bar #cli #unicode #indicator #set #display

yapb

Lightweight, pure, and unopinionated Unicode progress visualization

7 releases

Uses old Rust 2015

0.3.2 Nov 4, 2018
0.3.1 Jan 1, 2018
0.2.0 Dec 30, 2017
0.1.2 Dec 27, 2017

#857 in Command-line interface

26 downloads per month

Apache-2.0

16KB
312 lines

Yet Another Progress Bar

This library provides lightweight tools for rendering progress indicators and related information. Unlike most similar libraries, it performs no IO internally, instead providing Display implementations. Handling the details of any particular output device is left to the user.

Examples

The termion crate can be used to implement good behavior on an ANSI terminal:

extern crate yapb;
extern crate termion;
use std::{thread, time};
use std::io::{self, Write};
use yapb::{Bar, Progress};

fn main() {
  let mut bar = Bar::new();
  print!("{}", termion::cursor::Save);
  for i in 0..100 {
    bar.set(i as f32 / 100.0);
    let (width, _) = termion::terminal_size().unwrap();
    print!("{}{}[{:width$}]",
           termion::clear::AfterCursor, termion::cursor::Restore,
           bar, width = width as usize - 2);
    io::stdout().flush().unwrap();
    thread::sleep(time::Duration::from_millis(100));
  }
}

No runtime deps