diff --git a/src/app.rs b/src/app.rs index f5e1c7e..802aa3d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -25,7 +25,7 @@ pub async fn run() -> anyhow::Result<()> { | None => Coord::fetch().await?, }; - thread::sleep(std::time::Duration::from_secs(1)); + thread::sleep(Duration::from_secs(1)); // ----------------------------------------------------------------------------------------------- // 2. Load relays from file and filter them. @@ -43,7 +43,12 @@ pub async fn run() -> anyhow::Result<()> { let relays = loader.load()?; - thread::sleep(std::time::Duration::from_secs(1)); + thread::sleep(Duration::from_secs(1)); + + if relays.is_empty() { + spinner.stop(); + anyhow::bail!("Couldn't find any relays"); + } // ----------------------------------------------------------------------------------------------- // 3. Ping relays. diff --git a/src/cli.rs b/src/cli.rs index bfee026..d3f2ec9 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -101,8 +101,11 @@ impl Spinner { } /// Sets the message of the spinner. - pub fn set_message(&self, message: &'static str) { - self.spinner.set_message(message); + pub fn set_message(&self, message: S) + where + S: Into + AsRef, + { + self.spinner.set_message(message.into()); } /// Stops the spinner and clears the message.