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");

// Use a progress bar along with an iterator, eliminating the need for invoking inc or update.
for _ in pb.with_iter(0..100) {
    // ...
}

§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 fearlessly.

§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("");
}

§Style

avance provides a range of pre-definded progress styles (at Style), and also allows users to easily customize the style according to their preferences.

for _ in (0..1000).avance().with_style_str("=>-") {
    // ...
}

§TODOs:

  • A progress bar for io pipes
  • A Monitor for very slow progress bars

Modules§

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

Structs§

AvanceBar
The progress bar
AvanceBarIter
Wraps an AvanceIter and gives a progress bar handler when iterating.
AvanceIter
An iterator wrapper that shows a progress bar

Enums§

Style
Styles of a progress bar

Traits§

AvanceIterator
Wrap an iterator to display its progress

Functions§

set_max_progress_bars
Set how many on-going progress bar can be shown on the screen.