forked from console-rs/indicatif
-
Notifications
You must be signed in to change notification settings - Fork 1
/
morebars.rs
32 lines (28 loc) · 877 Bytes
/
morebars.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
fn main() {
let m = Arc::new(MultiProgress::new());
let sty = ProgressStyle::default_bar().template("{bar:40.green/yellow} {pos:>7}/{len:7}");
let pb = m.add(ProgressBar::new(5));
pb.set_style(sty.clone());
let m2 = m.clone();
let _ = thread::spawn(move || {
// make sure we show up at all. otherwise no rendering
// event.
pb.tick();
for _ in 0..5 {
let pb2 = m2.add(ProgressBar::new(128));
pb2.set_style(sty.clone());
for _ in 0..128 {
pb2.inc(1);
thread::sleep(Duration::from_millis(5));
}
pb2.finish();
pb.inc(1);
}
pb.finish_with_message("done");
})
.join();
}