From 7f33bdc9abc86114b87f61f0fb19de5928ccae43 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 18 Oct 2024 18:07:37 +0200 Subject: [PATCH] feat(main): relay switching by substring match --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index afb008e..ea89198 100644 --- a/src/main.rs +++ b/src/main.rs @@ -409,6 +409,16 @@ async fn main() -> Result<()> { let arg_default = arg.unwrap_or(""); match operator { Some(':') => { + if command.starts_with("://") { + if let Some((url, tasks)) = relays.iter().find(|(key, _)| key.as_ref().is_some_and(|url| url.as_str().contains(&command))) { + selected_relay.clone_from(url); + println!("{}", tasks); + continue 'repl; + } + warn!("No connected relay contains {:?}", command); + continue 'repl; + } + let mut iter = arg_default.chars(); let next = iter.next(); let remaining = iter.collect::().trim().to_string();