diff options
| author | Ellie Huxtable <ellie@atuin.sh> | 2024-07-30 16:54:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-30 16:54:10 +0100 |
| commit | 808138de633e410c1d3867d4fb7cb74967647605 (patch) | |
| tree | f180b7066b91d8d8d8006219a118439be1621d74 /ui/backend/src/install.rs | |
| parent | chore(deps): bump debian (#2320) (diff) | |
| download | atuin-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/install.rs')
| -rw-r--r-- | ui/backend/src/install.rs | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/ui/backend/src/install.rs b/ui/backend/src/install.rs deleted file mode 100644 index 17896e3a..00000000 --- a/ui/backend/src/install.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Handle installing the Atuin CLI -// We can use the standard install script for this - -use std::process::Command; - -use tokio::{ - fs::{read_to_string, OpenOptions}, - io::AsyncWriteExt, -}; - -use atuin_common::shell::Shell; - -#[tauri::command] -pub(crate) async fn install_cli() -> Result<(), String> { - let output = Command::new("sh") - .arg("-c") - .arg("curl --proto '=https' --tlsv1.2 -LsSf https://github.com/atuinsh/atuin/releases/latest/download/atuin-installer.sh | sh") - .output().map_err(|e|format!("Failed to execute Atuin installer: {e}")); - - Ok(()) -} - -#[tauri::command] -pub(crate) async fn is_cli_installed() -> Result<bool, String> { - let shell = Shell::default_shell().map_err(|e| format!("Failed to get default shell: {e}"))?; - let output = if shell == Shell::Powershell { - shell - .run_interactive(&["atuin --version; if ($?) {echo 'ATUIN FOUND'}"]) - .map_err(|e| format!("Failed to run interactive command"))? - } else { - shell - .run_interactive(&["atuin --version && echo 'ATUIN FOUND'"]) - .map_err(|e| format!("Failed to run interactive command"))? - }; - - Ok(output.contains("ATUIN FOUND")) -} - -#[tauri::command] -pub(crate) async fn setup_cli() -> Result<(), String> { - let shell = Shell::default_shell().map_err(|e| format!("Failed to get default shell: {e}"))?; - let config_file_path = shell.config_file(); - - if config_file_path.is_none() { - return Err("Failed to fetch default config file".to_string()); - } - - let config_file_path = config_file_path.unwrap(); - let config_file = read_to_string(config_file_path.clone()) - .await - .map_err(|e| format!("Failed to read config file: {e}"))?; - - if config_file.contains("atuin init") { - return Ok(()); - } - - let mut file = OpenOptions::new() - .write(true) - .append(true) - .open(config_file_path) - .await - .unwrap(); - - let config = format!( - "if [ -x \"$(command -v atuin)\" ]; then eval \"$(atuin init {})\"; fi", - shell.to_string() - ); - file.write_all(config.as_bytes()) - .await - .map_err(|e| format!("Failed to write Atuin shell init: {e}")); - - Ok(()) -} |
