https://github.com/sourcefrog/cargo-mutants
Nutmeg draws terminal progress indicators while giving the application complete control over their appearance and content.
For more information: https://docs.rs/nutmeg
License: MIT
From examples/basic.rs
:
```rust use std::io::Write; // to support write!()
// 1. Define a struct holding all the application state necessary to // render the progress bar.
struct Model { i: usize, total: usize, lastfilename: String, }
// 2. Define how to render the progress bar as a String. impl nutmeg::Model for Model { fn render(&mut self, width: usize) -> String { format!("{}/{}: {}", self.i, self.total, self.lastfile_name) } }
fn main() -> std::io::Result<()> { // 3. Create a View when you want to draw a progress bar. let mut view = nutmeg::View::new(Model::default(), nutmeg::ViewOptions::default());
// 4. As the application runs, update the model via the view.
for i in 0..100 {
view.update(|model| {
model.i += 1;
model.last_file_name = format!("file{}.txt", i);
});
// 5. Interleave text output lines by writing to the view.
if i % 10 == 3 {
writeln!(view, "reached {}", i)?;
}
std::thread::sleep(std::time::Duration::from_millis(100));
}
// 5. The bar is automatically erased when dropped.
Ok(())
} ```