diff --git a/src/platform.rs b/src/platform.rs index d859a0b..9b15687 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -1,6 +1,6 @@ use anyhow::Result; use crate::{ ConfigManager, config::Host, input }; -use dialoguer::{ Select, Input, theme::ColorfulTheme }; +use dialoguer::{ Select, Input, Confirm, theme::ColorfulTheme }; use serde::{ Serialize, Deserialize }; use ssh_key::PrivateKey; use std::fs; @@ -165,6 +165,7 @@ Host {host} .arg(host.host.to_owned()).spawn()?.wait()?; } 1 => { // Edit config + // TODO: replace this with configuer::editor let editor = std::env::var("EDITOR").expect("EDITOR is not set"); std::process::Command::new(editor) .arg(host.config.to_owned()) @@ -177,9 +178,16 @@ Host {host} config.save(); } 3 => { // Delete - config.configs.remove(host); - config.save(); - break; + let confirm = Confirm::with_theme(&ColorfulTheme::default()) + .with_prompt("Are you sure you want to delete this definition?") + .default(false) + .interact()?; + + if confirm { + config.configs.remove(host); + config.save(); + break; + } } // Back 4 => break, _ => ()