Crate avance

source ·
Expand description

avance is a rust library that helps you easily report progress in command line applications. It supports tracing progress in concurrent programs, and also offers various utilities for customizing a progress bar.

avance means advance or progress in spanish. This naming was inspired by tqdm, which was named after an arabic word.

Here is an example of using avance in multiple threads:

Platform support

  • Linux
  • macOS
  • Windows

Progress Bar

AvanceBar satisfies common usage of tracing progress. It can display necessary progress statistics, and can be used in the bounded or unbounded way.

use avance::AvanceBar;

let pb = AvanceBar::new(100);
for _ in 0..100 {
    // ...
    pb.inc();
}
// Don't need to close a bar manually. It will close automatically when being dropped.

You’re able to adjust the width, style and many other configs of a progress bar.

use avance::{AvanceBar, Style};

let pb = AvanceBar::new(100)
    .with_style(Style::Balloon)
    .with_width(80)
    .with_desc("avance");

Behaviors:

  • A progress bar will refresh when:
    • new or close
    • inc or update
    • configuration changes (such as changing its style or width)
  • If a progress bar’s width is too large, environment width will be used instead.
  • A progress bar can be shared among threads safely.

Iterator

Progress bar can also be associated with an iterator.

use avance::{AvanceIterator, Style};

for _ in (0..100).avance().with_style(Style::ASCII).with_width(80) {
    // ...
}

// avance provides the flexibility of changing a progress bar when iterating
for (_, pb) in (0..100).avance().with_pb() {
    // ...
    pb.set_postfix("");
}

TODOs:

  • Support user-defined progress bar style
  • Implement Read & Write traits for AvanceIter

Re-exports

Modules

  • A progress bar and all utilities.
  • A wrapped iterator that shows progress
  • Styles of a progress bar