Crates.io | multi-progressbar |
lib.rs | multi-progressbar |
version | 0.1.0 |
source | src |
created_at | 2023-07-12 07:52:51.160942 |
updated_at | 2023-07-12 07:52:51.160942 |
description | A library for displaying multiple progress bars in the terminal designed to not stand in your way. |
homepage | |
repository | https://github.com/eternal-flame-AD/multi-progressbar |
max_upload_size | |
id | 914356 |
size | 26,081 |
multi-progress is a library to show multiple progress bars along with log outputs in terminal.
TaskProgress
trait for your task.MultiProgressBar
with a ProgressBar
implementation (provided in the bar module).MultiProgressBar::draw
to draw progress bars when needed.use multi_progressbar::{
MultiProgressBar, TaskProgress,
bar::classic::ClassicProgressBar
};
struct Task {
name: String,
progress: u64,
total: u64,
}
impl TaskProgress for Task {
fn progress(&self) -> (u64, u64) {
(self.progress, self.total)
}
fn after(&self) -> Option<String> {
Some(format!("{}/{} completed", self.progress, self.total))
}
fn before(&self) -> Option<String> {
Some(self.name.clone())
}
}
let mp = MultiProgressBar::new(ClassicProgressBar::new());
let task1 = Task {
name: "task1".to_string(),
progress: 0,
total: 100,
};
let task2 = Task {
name: "task2".to_string(),
progress: 33,
total: 100,
};
let tasks = vec![task1, task2];
mp.draw(&tasks).unwrap();