add confirm prompt for deleting definitions
This commit is contained in:
parent
2ecccea343
commit
dc34e8e5f4
@ -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
|
||||
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,
|
||||
_ => ()
|
||||
|
Loading…
Reference in New Issue
Block a user