feat(main): relay switching by substring match

This commit is contained in:
xeruf 2024-10-18 18:07:37 +02:00
parent 306e0e0421
commit 7f33bdc9ab
1 changed files with 10 additions and 0 deletions

View File

@ -409,6 +409,16 @@ async fn main() -> Result<()> {
let arg_default = arg.unwrap_or(""); let arg_default = arg.unwrap_or("");
match operator { match operator {
Some(':') => { 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 mut iter = arg_default.chars();
let next = iter.next(); let next = iter.next();
let remaining = iter.collect::<String>().trim().to_string(); let remaining = iter.collect::<String>().trim().to_string();