use std::{ collections::HashSet, io::{stdout, Write}, }; use clap::Parser; use tokio::sync::mpsc; #[derive(Debug, Clone, Parser)] pub struct Config { /// Tmux socket name #[arg(short, long, default_value = "ssh")] pub socket: String, /// Exclude host from output (can be specified multiple times) #[arg(short, long)] pub exclude: Vec, } #[tokio::main] async fn main() -> Result<(), std::io::Error> { let config = Config::parse(); let (tx, mut rx) = mpsc::channel(100); tokio::spawn(sshr::tmux::sessions(tx.clone(), config.socket)); tokio::spawn(sshr::netlink::neighbours(tx.clone())); drop(tx); let mut output: HashSet = HashSet::from_iter(config.exclude.into_iter()); let mut stdout = stdout(); while let Some(host) = rx.recv().await { if output.insert(host.clone()) { writeln!(stdout, "{host}")?; } } Ok(()) }