Added missing --yes flag to innernet-server uninstall command (#221)

pull/222/head
Jon Prentice 2022-05-19 19:02:17 -07:00 committed by GitHub
parent 50a4360746
commit 43a9d51091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 9 deletions

View File

@ -71,7 +71,13 @@ enum Command {
}, },
/// Permanently uninstall a created network, rendering it unusable. Use with care. /// 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 the coordinating server for an existing network.
Serve { Serve {
@ -251,7 +257,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1); std::process::exit(1);
} }
}, },
Command::Uninstall { interface } => uninstall(&interface, &conf, opts.network)?, Command::Uninstall { interface, yes } => uninstall(&interface, &conf, opts.network, yes)?,
Command::Serve { Command::Serve {
interface, interface,
network: routing, network: routing,
@ -413,14 +419,16 @@ fn uninstall(
interface: &InterfaceName, interface: &InterfaceName,
conf: &ServerConfig, conf: &ServerConfig,
network: NetworkOpts, network: NetworkOpts,
yes: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
if Confirm::with_theme(&*prompts::THEME) if yes
.with_prompt(&format!( || Confirm::with_theme(&*prompts::THEME)
"Permanently delete network \"{}\"?", .with_prompt(&format!(
interface.as_str_lossy().yellow() "Permanently delete network \"{}\"?",
)) interface.as_str_lossy().yellow()
.default(false) ))
.interact()? .default(false)
.interact()?
{ {
println!("{} bringing down interface (if up).", "[*]".dimmed()); println!("{} bringing down interface (if up).", "[*]".dimmed());
wg::down(interface, network.backend).ok(); wg::down(interface, network.backend).ok();