21 releases (4 breaking)
0.6.5 | Jul 13, 2023 |
---|---|
0.6.4 | Jul 12, 2023 |
0.5.1 | Jul 5, 2023 |
0.4.4 | Jul 1, 2023 |
0.1.0 |
|
#817 in Command-line interface
93 downloads per month
Used in avance-cli
33KB
604 lines
A Rust library for easily displaying progress bar in command line applications.
avance provides out of box progress bar utilites, which are lightweight, user-friendly and can be used fearlessly in a concurrent environment.
Examples
lib.rs
:
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:
- 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
Dependencies
~1.5–9MB
~74K SLoC