delete host config folder when deleting host definition
This commit is contained in:
parent
dc34e8e5f4
commit
73be0cbd4e
@ -30,12 +30,12 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
let mut config: ConfigManager = ConfigManager::new(config_root, search_path)?;
|
let mut config: ConfigManager = ConfigManager::new(config_root, search_path)?;
|
||||||
|
|
||||||
let backend = TermionBackend::new(io::stdout().into_alternate_screen()?);
|
// let backend = TermionBackend::new(io::stdout().into_alternate_screen()?);
|
||||||
// let backend = TermionBackend::new(io::stdout()); // used for debugging
|
let backend = TermionBackend::new(io::stdout()); // used for debugging
|
||||||
let mut term = Terminal::new(backend)?;
|
let mut term = Terminal::new(backend)?;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
term.clear()?;
|
// term.clear()?;
|
||||||
|
|
||||||
let mut host = input::get_host(&mut config)?;
|
let mut host = input::get_host(&mut config)?;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crate::{ ConfigManager, config::Host, input };
|
use crate::{ ConfigManager, config::Host, input };
|
||||||
use dialoguer::{ Select, Input, Confirm, theme::ColorfulTheme };
|
use dialoguer::{ Select, Input, Confirm, Editor, theme::ColorfulTheme };
|
||||||
use serde::{ Serialize, Deserialize };
|
use serde::{ Serialize, Deserialize };
|
||||||
use ssh_key::PrivateKey;
|
use ssh_key::PrivateKey;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
@ -166,6 +166,9 @@ Host {host}
|
|||||||
}
|
}
|
||||||
1 => { // Edit config
|
1 => { // Edit config
|
||||||
// TODO: replace this with configuer::editor
|
// TODO: replace this with configuer::editor
|
||||||
|
// if let Some(cnf) = Editor::new().edit(fs::read_to_string(config.config_dir.join("config"))?.as_str())? {
|
||||||
|
// fs::write(config.config_dir.join("config"), cnf)?;
|
||||||
|
// }
|
||||||
let editor = std::env::var("EDITOR").expect("EDITOR is not set");
|
let editor = std::env::var("EDITOR").expect("EDITOR is not set");
|
||||||
std::process::Command::new(editor)
|
std::process::Command::new(editor)
|
||||||
.arg(host.config.to_owned())
|
.arg(host.config.to_owned())
|
||||||
@ -184,8 +187,12 @@ Host {host}
|
|||||||
.interact()?;
|
.interact()?;
|
||||||
|
|
||||||
if confirm {
|
if confirm {
|
||||||
|
let mut conf = std::path::PathBuf::from(host.config.to_owned());
|
||||||
|
conf.pop();
|
||||||
|
|
||||||
config.configs.remove(host);
|
config.configs.remove(host);
|
||||||
config.save();
|
config.save();
|
||||||
|
fs::remove_dir_all(conf)?;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // Back
|
} // Back
|
||||||
|
Loading…
Reference in New Issue
Block a user