diff options
Diffstat (limited to 'atuin/src/command')
-rw-r--r-- | atuin/src/command/client/history.rs | 2 | ||||
-rw-r--r-- | atuin/src/command/client/init/bash.rs | 3 | ||||
-rw-r--r-- | atuin/src/command/client/init/fish.rs | 3 | ||||
-rw-r--r-- | atuin/src/command/client/init/xonsh.rs | 3 | ||||
-rw-r--r-- | atuin/src/command/client/init/zsh.rs | 3 | ||||
-rw-r--r-- | atuin/src/command/client/store/pull.rs | 12 | ||||
-rw-r--r-- | atuin/src/command/client/store/rebuild.rs | 16 | ||||
-rw-r--r-- | atuin/src/command/client/sync.rs | 4 |
8 files changed, 25 insertions, 21 deletions
diff --git a/atuin/src/command/client/history.rs b/atuin/src/command/client/history.rs index e5acc8b1..b9e54b50 100644 --- a/atuin/src/command/client/history.rs +++ b/atuin/src/command/client/history.rs @@ -365,7 +365,7 @@ impl Cmd { let (_, downloaded) = record::sync::sync(settings, &store).await?; Settings::save_sync_time()?; - history_store.incremental_build(db, &downloaded).await?; + crate::sync::build(settings, &store, db, Some(&downloaded)).await?; } else { debug!("running periodic background sync"); sync::sync(settings, false, db).await?; diff --git a/atuin/src/command/client/init/bash.rs b/atuin/src/command/client/init/bash.rs index 2fd7c195..6e7f14e7 100644 --- a/atuin/src/command/client/init/bash.rs +++ b/atuin/src/command/client/init/bash.rs @@ -18,8 +18,7 @@ pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool) { pub async fn init(store: AliasStore, disable_up_arrow: bool, disable_ctrl_r: bool) -> Result<()> { init_static(disable_up_arrow, disable_ctrl_r); - let aliases = store.aliases().await?; - let aliases = atuin_dotfiles::shell::bash::build(&aliases[..]); + let aliases = atuin_dotfiles::shell::bash::config(&store).await; println!("{aliases}"); diff --git a/atuin/src/command/client/init/fish.rs b/atuin/src/command/client/init/fish.rs index 83bf0500..4ec74952 100644 --- a/atuin/src/command/client/init/fish.rs +++ b/atuin/src/command/client/init/fish.rs @@ -37,8 +37,7 @@ bind -M insert \e\[A _atuin_bind_up"; pub async fn init(store: AliasStore, disable_up_arrow: bool, disable_ctrl_r: bool) -> Result<()> { init_static(disable_up_arrow, disable_ctrl_r); - let aliases = store.aliases().await?; - let aliases = atuin_dotfiles::shell::fish::build(&aliases[..]); + let aliases = atuin_dotfiles::shell::fish::config(&store).await; println!("{aliases}"); diff --git a/atuin/src/command/client/init/xonsh.rs b/atuin/src/command/client/init/xonsh.rs index 75ab4a1a..cfe64f7e 100644 --- a/atuin/src/command/client/init/xonsh.rs +++ b/atuin/src/command/client/init/xonsh.rs @@ -23,8 +23,7 @@ pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool) { pub async fn init(store: AliasStore, disable_up_arrow: bool, disable_ctrl_r: bool) -> Result<()> { init_static(disable_up_arrow, disable_ctrl_r); - let aliases = store.aliases().await?; - let aliases = atuin_dotfiles::shell::xonsh::build(&aliases[..]); + let aliases = atuin_dotfiles::shell::xonsh::config(&store).await; println!("{aliases}"); diff --git a/atuin/src/command/client/init/zsh.rs b/atuin/src/command/client/init/zsh.rs index 574047a4..2341e203 100644 --- a/atuin/src/command/client/init/zsh.rs +++ b/atuin/src/command/client/init/zsh.rs @@ -31,8 +31,7 @@ bindkey -M vicmd 'k' atuin-up-search-vicmd"; pub async fn init(store: AliasStore, disable_up_arrow: bool, disable_ctrl_r: bool) -> Result<()> { init_static(disable_up_arrow, disable_ctrl_r); - let aliases = store.aliases().await?; - let aliases = atuin_dotfiles::shell::zsh::build(&aliases[..]); + let aliases = atuin_dotfiles::shell::zsh::config(&store).await; println!("{aliases}"); diff --git a/atuin/src/command/client/store/pull.rs b/atuin/src/command/client/store/pull.rs index d920dd21..36450fbf 100644 --- a/atuin/src/command/client/store/pull.rs +++ b/atuin/src/command/client/store/pull.rs @@ -1,10 +1,8 @@ use clap::Args; -use eyre::{Result, WrapErr}; +use eyre::Result; use atuin_client::{ database::Database, - encryption, - history::store::HistoryStore, record::store::Store, record::sync::Operation, record::{sqlite_store::SqliteStore, sync}, @@ -73,13 +71,7 @@ impl Pull { println!("Downloaded {} records", downloaded.len()); - let encryption_key: [u8; 32] = encryption::load_key(settings) - .context("could not load encryption key")? - .into(); - - let host_id = Settings::host_id().expect("failed to get host_id"); - let history_store = HistoryStore::new(store.clone(), host_id, encryption_key); - history_store.incremental_build(db, &downloaded).await?; + crate::sync::build(settings, &store, db, Some(&downloaded)).await?; Ok(()) } diff --git a/atuin/src/command/client/store/rebuild.rs b/atuin/src/command/client/store/rebuild.rs index 880647b4..f99d3247 100644 --- a/atuin/src/command/client/store/rebuild.rs +++ b/atuin/src/command/client/store/rebuild.rs @@ -1,3 +1,4 @@ +use atuin_dotfiles::store::AliasStore; use clap::Args; use eyre::{bail, Result}; @@ -28,6 +29,10 @@ impl Rebuild { .await?; } + "dotfiles" => { + self.rebuild_dotfiles(settings, store.clone()).await?; + } + tag => bail!("unknown tag: {tag}"), } @@ -49,4 +54,15 @@ impl Rebuild { Ok(()) } + + async fn rebuild_dotfiles(&self, settings: &Settings, store: SqliteStore) -> Result<()> { + let encryption_key: [u8; 32] = encryption::load_key(settings)?.into(); + + let host_id = Settings::host_id().expect("failed to get host_id"); + let alias_store = AliasStore::new(store, host_id, encryption_key); + + alias_store.build().await?; + + Ok(()) + } } diff --git a/atuin/src/command/client/sync.rs b/atuin/src/command/client/sync.rs index 4889cbca..be1bf6d2 100644 --- a/atuin/src/command/client/sync.rs +++ b/atuin/src/command/client/sync.rs @@ -90,7 +90,7 @@ async fn run( let (uploaded, downloaded) = sync::sync(settings, &store).await?; - history_store.incremental_build(db, &downloaded).await?; + crate::sync::build(settings, &store, db, Some(&downloaded)).await?; println!("{uploaded}/{} up/down to record store", downloaded.len()); @@ -113,7 +113,7 @@ async fn run( // we'll want to run sync once more, as there will now be stuff to upload let (uploaded, downloaded) = sync::sync(settings, &store).await?; - history_store.incremental_build(db, &downloaded).await?; + crate::sync::build(settings, &store, db, Some(&downloaded)).await?; println!("{uploaded}/{} up/down to record store", downloaded.len()); } |