aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/store.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-09 21:43:23 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-09 21:43:23 +0200
commit3223d93cb3c77ab02aa0a35f2a8314e447cee9a4 (patch)
tree3971a1f37f5fe3cadb747c5229a0d54e868e45e3 /crates/turtle/src/command/client/store.rs
parentfix(client/sync): Pass through precise error on `SyncError::WrongKey` (diff)
downloadatuin-3223d93cb3c77ab02aa0a35f2a8314e447cee9a4.zip
chore: Separate daemon, client, server, and lib into crates
Diffstat (limited to 'crates/turtle/src/command/client/store.rs')
-rw-r--r--crates/turtle/src/command/client/store.rs108
1 files changed, 0 insertions, 108 deletions
diff --git a/crates/turtle/src/command/client/store.rs b/crates/turtle/src/command/client/store.rs
deleted file mode 100644
index bc57488d..00000000
--- a/crates/turtle/src/command/client/store.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-use clap::Subcommand;
-use eyre::Result;
-
-use crate::atuin_client::{
- database::ClientSqlite, record::sqlite_store::SqliteStore, settings::Settings,
-};
-use itertools::Itertools;
-use time::{OffsetDateTime, UtcOffset};
-
-mod pull;
-mod purge;
-mod push;
-mod rebuild;
-mod rekey;
-mod verify;
-
-#[derive(Subcommand, Debug)]
-#[command(infer_subcommands = true)]
-pub(crate) enum Cmd {
- /// Print the current status of the record store
- Status,
-
- /// Rebuild a store (eg atuin store rebuild history)
- Rebuild(rebuild::Rebuild),
-
- /// Re-encrypt the store with a new key (potential for data loss!)
- Rekey(rekey::Rekey),
-
- /// Delete all records in the store that cannot be decrypted with the current key
- Purge(purge::Purge),
-
- /// Verify that all records in the store can be decrypted with the current key
- Verify(verify::Verify),
-
- /// Push all records to the remote sync server (one way sync)
- Push(push::Push),
-
- /// Pull records from the remote sync server (one way sync)
- Pull(pull::Pull),
-}
-
-impl Cmd {
- pub(crate) async fn run(
- &self,
- settings: &Settings,
- database: &ClientSqlite,
- store: SqliteStore,
- ) -> Result<()> {
- match self {
- Self::Status => self.status(store).await,
- Self::Rebuild(rebuild) => rebuild.run(settings, store, database).await,
- Self::Rekey(rekey) => rekey.run(settings, store).await,
- Self::Verify(verify) => verify.run(settings, store).await,
- Self::Purge(purge) => purge.run(settings, store).await,
- Self::Push(push) => push.run(settings, store).await,
- Self::Pull(pull) => pull.run(settings, store, database).await,
- }
- }
-
- pub(crate) async fn status(&self, store: SqliteStore) -> Result<()> {
- let host_id = Settings::host_id().await?;
- let offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC);
-
- let status = store.status().await?;
-
- // TODO: should probs build some data structure and then pretty-print it or smth
- for (host, st) in status.hosts.iter().sorted_by_key(|(h, _)| *h) {
- let host_string = if host == &host_id {
- format!("host: {} <- CURRENT HOST", host.0.as_hyphenated())
- } else {
- format!("host: {}", host.0.as_hyphenated())
- };
-
- println!("{host_string}");
-
- for (tag, idx) in st.iter().sorted_by_key(|(tag, _)| *tag) {
- println!("\tstore: {tag}");
-
- let first = store.first(*host, tag).await?;
- let last = store.last(*host, tag).await?;
-
- println!("\t\tidx: {idx}");
-
- if let Some(first) = first {
- println!("\t\tfirst: {}", first.id.0.as_hyphenated());
-
- let time =
- OffsetDateTime::from_unix_timestamp_nanos(i128::from(first.timestamp))?
- .to_offset(offset);
- println!("\t\t\tcreated: {time}");
- }
-
- if let Some(last) = last {
- println!("\t\tlast: {}", last.id.0.as_hyphenated());
-
- let time =
- OffsetDateTime::from_unix_timestamp_nanos(i128::from(last.timestamp))?
- .to_offset(offset);
- println!("\t\t\tcreated: {time}");
- }
- }
-
- println!();
- }
-
- Ok(())
- }
-}