From 00568953fe23ca2006c6d4b9c81fc97a6043a0f5 Mon Sep 17 00:00:00 2001 From: Matthias Herzog <37505324+kegato@users.noreply.github.com> Date: Wed, 14 Nov 2018 12:23:24 +0100 Subject: [PATCH] add static wait interval fixes #2 --- src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index be14ffe..728a1df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,14 @@ fn run() -> Result<(), String> { ) .arg(Arg::with_name("nodnscheck") .long("no-dns-check") - .help("Don't wait for the dns record to be publicly visible") + .help("don't wait for the dns record to be publicly visible") + ) + .arg(Arg::with_name("waitinterval") + .long("wait-interval") + .value_name("SECONDS") + .help("the amount of seconds to wait after creating a record") + .takes_value(true) + .default_value("5") ) ) .subcommand(SubCommand::with_name("delete") @@ -94,6 +101,7 @@ fn run() -> Result<(), String> { let domain = lookup_real_domain(matches.value_of("domain").unwrap()); let value = matches.value_of("value").unwrap(); let (user, pass) = read_credentials(matches.value_of("credentialfile").unwrap())?; + let wait_interval = matches.value_of("waitinterval").unwrap().parse().map_err(|_| "Invalid wait interval!")?; println!("Creating TXT record..."); @@ -127,6 +135,14 @@ fn run() -> Result<(), String> { println!("=> done!"); } + + if wait_interval > 0 { + println!("Waiting {} additional seconds...", &wait_interval); + + sleep(Duration::from_secs(wait_interval)); + + println!("=> done!"); + } } else if let Some(matches) = matches.subcommand_matches("delete") { let domain = lookup_real_domain(matches.value_of("domain").unwrap()); let (user, pass) = read_credentials(matches.value_of("credentialfile").unwrap())?;