aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/history
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-02-08 13:34:41 +0000
committerGitHub <noreply@github.com>2024-02-08 13:34:41 +0000
commit8460210202af4e48ea55c997bf2739a6f0570e4a (patch)
treeb65b7ec55da171d9246be0d2ef77a7e39ecf45cb /atuin-client/src/history
parentfix(tests): add Settings::utc() for utc settings (#1677) (diff)
downloadatuin-8460210202af4e48ea55c997bf2739a6f0570e4a.zip
feat: add progress bars to sync and store init (#1684)
Replace lots of logging with some progress bars. This looks much nicer I'd like to move it out of the atuin-client crate and into the atuin crate. But first, I want to decouple a lot of the record moving, so it can wait until that's done.
Diffstat (limited to 'atuin-client/src/history')
-rw-r--r--atuin-client/src/history/store.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/atuin-client/src/history/store.rs b/atuin-client/src/history/store.rs
index 08c55c51..4a4cb1ab 100644
--- a/atuin-client/src/history/store.rs
+++ b/atuin-client/src/history/store.rs
@@ -1,6 +1,7 @@
-use std::collections::HashSet;
+use std::{collections::HashSet, fmt::Write};
use eyre::{bail, eyre, Result};
+use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use rmp::decode::Bytes;
use crate::{
@@ -263,11 +264,17 @@ impl HistoryStore {
println!("Fetching history already in store");
let store_ids = self.history_ids().await?;
+ let pb = ProgressBar::new(history.len() as u64);
+ pb.set_style(ProgressStyle::with_template("{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {human_pos}/{human_len} ({eta})")
+ .unwrap()
+ .with_key("eta", |state: &ProgressState, w: &mut dyn Write| write!(w, "{:.1}s", state.eta().as_secs_f64()).unwrap())
+ .progress_chars("#>-"));
+
for i in history {
- println!("loaded {}", i.id);
+ debug!("loaded {}", i.id);
if store_ids.contains(&i.id) {
- println!("skipping {} - already exists", i.id);
+ debug!("skipping {} - already exists", i.id);
continue;
}
@@ -277,8 +284,12 @@ impl HistoryStore {
} else {
self.push(i).await?;
}
+
+ pb.inc(1);
}
+ pb.finish_with_message("Import complete");
+
Ok(())
}
}