diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-01-12 22:03:48 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-01-12 22:03:48 +0100 |
commit | 4042105e6d6a711dfec353b9cd9932fd9bf9c8af (patch) | |
tree | 65da9b4c461888d30cbdaf0865e9eb0540c4e65e | |
parent | 3826d00f339e87698f95dc24c33739e2880aac65 (diff) | |
download | hittekaart-4042105e6d6a711dfec353b9cd9932fd9bf9c8af.tar.gz hittekaart-4042105e6d6a711dfec353b9cd9932fd9bf9c8af.tar.bz2 hittekaart-4042105e6d6a711dfec353b9cd9932fd9bf9c8af.zip |
make progress bars a bit nicer
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index e066a95..1859243 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::{env, fs, path::PathBuf}; use color_eyre::eyre::Result; -use indicatif::ProgressBar; +use indicatif::{ProgressBar, ProgressStyle}; mod gpx; mod layer; @@ -10,6 +10,9 @@ mod renderer; fn main() -> Result<()> { color_eyre::install()?; + let progress_style = + ProgressStyle::with_template("[{elapsed}] {prefix:.cyan} {wide_bar} {pos:.green}/{len}")?; + let gpx_folder = env::args().nth(1).unwrap(); println!("Reading from {gpx_folder}"); @@ -23,7 +26,9 @@ fn main() -> Result<()> { for zoom in 0..=19 { println!("Doing level {zoom}"); - let bar = ProgressBar::new(tracks.len().try_into().unwrap()); + let bar = + ProgressBar::new(tracks.len().try_into().unwrap()).with_style(progress_style.clone()); + bar.set_prefix("Rendering heat zones"); let counter = renderer::render_heatcounter(zoom, &tracks, |x| bar.inc(x.try_into().unwrap())); bar.finish(); @@ -31,7 +36,9 @@ fn main() -> Result<()> { let target = ["tiles", &zoom.to_string()].iter().collect::<PathBuf>(); fs::create_dir(&target)?; - let bar = ProgressBar::new(counter.tile_count().try_into().unwrap()); + let bar = ProgressBar::new(counter.tile_count().try_into().unwrap()) + .with_style(progress_style.clone()); + bar.set_prefix("Saving heat tiles"); renderer::lazy_colorization(&counter, &target, |x| bar.inc(x.try_into().unwrap()))?; bar.finish(); } |