From 43a9d510918921dda69a2c1a2b2aa7658b9f290d Mon Sep 17 00:00:00 2001 From: Jon Prentice Date: Thu, 19 May 2022 19:02:17 -0700 Subject: [PATCH] Added missing --yes flag to innernet-server uninstall command (#221) --- server/src/main.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index cd26d75..1109352 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -71,7 +71,13 @@ enum Command { }, /// Permanently uninstall a created network, rendering it unusable. Use with care. - Uninstall { interface: Interface }, + Uninstall { + interface: Interface, + + /// Bypass confirmation + #[clap(long)] + yes: bool, + }, /// Serve the coordinating server for an existing network. Serve { @@ -251,7 +257,7 @@ async fn main() -> Result<(), Box> { std::process::exit(1); } }, - Command::Uninstall { interface } => uninstall(&interface, &conf, opts.network)?, + Command::Uninstall { interface, yes } => uninstall(&interface, &conf, opts.network, yes)?, Command::Serve { interface, network: routing, @@ -413,14 +419,16 @@ fn uninstall( interface: &InterfaceName, conf: &ServerConfig, network: NetworkOpts, + yes: bool, ) -> Result<(), Error> { - if Confirm::with_theme(&*prompts::THEME) - .with_prompt(&format!( - "Permanently delete network \"{}\"?", - interface.as_str_lossy().yellow() - )) - .default(false) - .interact()? + if yes + || Confirm::with_theme(&*prompts::THEME) + .with_prompt(&format!( + "Permanently delete network \"{}\"?", + interface.as_str_lossy().yellow() + )) + .default(false) + .interact()? { println!("{} bringing down interface (if up).", "[*]".dimmed()); wg::down(interface, network.backend).ok();