move bar creation

This commit is contained in:
Magnus Ulimoen 2020-04-06 22:42:44 +02:00
parent 50ddf0acce
commit 13abdefe57
1 changed files with 13 additions and 9 deletions

View File

@ -428,15 +428,7 @@ fn main() {
add_timestep_to_file(&file, 0, sys.fnow.as_slice()).unwrap(); add_timestep_to_file(&file, 0, sys.fnow.as_slice()).unwrap();
} }
let bar = if opt.no_progressbar { let bar = progressbar(opt.no_progressbar, ntime);
indicatif::ProgressBar::hidden()
} else {
let bar = indicatif::ProgressBar::new(ntime as _);
bar.with_style(
indicatif::ProgressStyle::default_bar()
.template("{wide_bar:.cyan/blue} {pos}/{len} ({eta})"),
)
};
for _ in 0..ntime { for _ in 0..ntime {
bar.inc(1); bar.inc(1);
if let Some(pool) = pool.as_ref() { if let Some(pool) = pool.as_ref() {
@ -454,6 +446,18 @@ fn main() {
} }
} }
fn progressbar(dummy: bool, ntime: u64) -> indicatif::ProgressBar {
if dummy {
indicatif::ProgressBar::hidden()
} else {
let bar = indicatif::ProgressBar::new(ntime);
bar.with_style(
indicatif::ProgressStyle::default_bar()
.template("{wide_bar:.cyan/blue} {pos}/{len} ({eta})"),
)
}
}
fn legacy_output<T: sbp::operators::UpwindOperator, P: AsRef<std::path::Path>>( fn legacy_output<T: sbp::operators::UpwindOperator, P: AsRef<std::path::Path>>(
path: &P, path: &P,
sys: &System<T>, sys: &System<T>,