aboutsummaryrefslogtreecommitdiffstats
path: root/ui/backend/src/dotfiles
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2024-07-30 16:54:10 +0100
committerGitHub <noreply@github.com>2024-07-30 16:54:10 +0100
commit808138de633e410c1d3867d4fb7cb74967647605 (patch)
treef180b7066b91d8d8d8006219a118439be1621d74 /ui/backend/src/dotfiles
parentchore(deps): bump debian (#2320) (diff)
downloadatuin-808138de633e410c1d3867d4fb7cb74967647605.zip
chore: remove ui directory (#2329)
This is still in development, but rather than clutter the commit history and issues with an unreleased project I've split the UI into its own repo. Once ready for release, I'll either merge the ui code back in, or just make the repo public.
Diffstat (limited to 'ui/backend/src/dotfiles')
-rw-r--r--ui/backend/src/dotfiles/aliases.rs91
-rw-r--r--ui/backend/src/dotfiles/mod.rs2
-rw-r--r--ui/backend/src/dotfiles/vars.rs57
3 files changed, 0 insertions, 150 deletions
diff --git a/ui/backend/src/dotfiles/aliases.rs b/ui/backend/src/dotfiles/aliases.rs
deleted file mode 100644
index 972466fe..00000000
--- a/ui/backend/src/dotfiles/aliases.rs
+++ /dev/null
@@ -1,91 +0,0 @@
-use std::path::PathBuf;
-
-use atuin_client::{encryption, record::sqlite_store::SqliteStore, settings::Settings};
-use atuin_common::shell::Shell;
-use atuin_dotfiles::{
- shell::{existing_aliases, Alias},
- store::AliasStore,
-};
-
-async fn alias_store() -> eyre::Result<AliasStore> {
- let settings = Settings::new()?;
-
- let record_store_path = PathBuf::from(settings.record_store_path.as_str());
- let sqlite_store = SqliteStore::new(record_store_path, settings.local_timeout).await?;
-
- let encryption_key: [u8; 32] = encryption::load_key(&settings)?.into();
-
- let host_id = Settings::host_id().expect("failed to get host_id");
-
- Ok(AliasStore::new(sqlite_store, host_id, encryption_key))
-}
-
-#[tauri::command]
-pub async fn aliases() -> Result<Vec<Alias>, String> {
- let alias_store = alias_store().await.map_err(|e| e.to_string())?;
-
- let aliases = alias_store
- .aliases()
- .await
- .map_err(|e| format!("failed to load aliases: {}", e))?;
-
- Ok(aliases)
-}
-
-#[tauri::command]
-pub async fn delete_alias(name: String) -> Result<(), String> {
- let alias_store = alias_store().await.map_err(|e| e.to_string())?;
-
- alias_store
- .delete(name.as_str())
- .await
- .map_err(|e| e.to_string())?;
-
- Ok(())
-}
-
-#[tauri::command]
-pub async fn set_alias(name: String, value: String) -> Result<(), String> {
- let alias_store = alias_store().await.map_err(|e| e.to_string())?;
-
- alias_store
- .set(name.as_str(), value.as_str())
- .await
- .map_err(|e| e.to_string())?;
-
- Ok(())
-}
-
-#[tauri::command]
-pub async fn import_aliases() -> Result<Vec<Alias>, String> {
- let store = alias_store().await.map_err(|e| e.to_string())?;
- let shell = Shell::default_shell().map_err(|e| e.to_string())?;
- let shell_name = shell.to_string();
-
- if !shell.is_posixish() {
- return Err(format!(
- "Default shell {shell_name} not supported for import"
- ));
- }
-
- let existing_aliases = existing_aliases(Some(shell)).map_err(|e| e.to_string())?;
- let store_aliases = store.aliases().await.map_err(|e| e.to_string())?;
-
- let mut res = Vec::new();
-
- for alias in existing_aliases {
- // O(n), but n is small, and imports infrequent
- // can always make a map
- if store_aliases.contains(&alias) {
- continue;
- }
-
- res.push(alias.clone());
- store
- .set(&alias.name, &alias.value)
- .await
- .map_err(|e| e.to_string())?;
- }
-
- Ok(res)
-}
diff --git a/ui/backend/src/dotfiles/mod.rs b/ui/backend/src/dotfiles/mod.rs
deleted file mode 100644
index feafe783..00000000
--- a/ui/backend/src/dotfiles/mod.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub mod aliases;
-pub mod vars;
diff --git a/ui/backend/src/dotfiles/vars.rs b/ui/backend/src/dotfiles/vars.rs
deleted file mode 100644
index d8d5bd75..00000000
--- a/ui/backend/src/dotfiles/vars.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-use std::path::PathBuf;
-
-use atuin_client::{encryption, record::sqlite_store::SqliteStore, settings::Settings};
-use atuin_common::shell::Shell;
-use atuin_dotfiles::{
- shell::{existing_aliases, Alias, Var},
- store::var::VarStore,
-};
-
-async fn var_store() -> eyre::Result<VarStore> {
- let settings = Settings::new()?;
-
- let record_store_path = PathBuf::from(settings.record_store_path.as_str());
- let sqlite_store = SqliteStore::new(record_store_path, settings.local_timeout).await?;
-
- let encryption_key: [u8; 32] = encryption::load_key(&settings)?.into();
-
- let host_id = Settings::host_id().expect("failed to get host_id");
-
- Ok(VarStore::new(sqlite_store, host_id, encryption_key))
-}
-
-#[tauri::command]
-pub async fn vars() -> Result<Vec<Var>, String> {
- let var_store = var_store().await.map_err(|e| e.to_string())?;
-
- let vars = var_store
- .vars()
- .await
- .map_err(|e| format!("failed to load aliases: {}", e))?;
-
- Ok(vars)
-}
-
-#[tauri::command]
-pub async fn delete_var(name: String) -> Result<(), String> {
- let var_store = var_store().await.map_err(|e| e.to_string())?;
-
- var_store
- .delete(name.as_str())
- .await
- .map_err(|e| e.to_string())?;
-
- Ok(())
-}
-
-#[tauri::command]
-pub async fn set_var(name: String, value: String, export: bool) -> Result<(), String> {
- let var_store = var_store().await.map_err(|e| e.to_string())?;
-
- var_store
- .set(name.as_str(), value.as_str(), export)
- .await
- .map_err(|e| e.to_string())?;
-
- Ok(())
-}