use std::{net::IpAddr, str::FromStr};
use airtouch5::AirTouch5;
use simplelog::TermLogger;
const USAGE_STR: &str = "Usage: info <ip>";
#[tokio::main(flavor = "current_thread")]
pub async fn main() {
TermLogger::init(
log::LevelFilter::Debug,
simplelog::Config::default(),
simplelog::TerminalMode::Mixed,
simplelog::ColorChoice::Auto,
)
.expect("could not init logger");
let addr = IpAddr::from_str(&std::env::args().nth(1).expect(USAGE_STR)).expect(USAGE_STR);
let controller = AirTouch5::with_ipaddr(addr)
.await
.expect("could not connect");
let vers = controller
.console_version()
.await
.expect("could not get console version");
println!(
"Airtouch 5 Console version{} {}{}",
if vers.versions.len() > 1 { "s" } else { "" },
vers.versions.join(", "),
if vers.update_available {
" (update available)"
} else {
""
}
);
let caps = controller
.ac_capabilities()
.await
.expect("could not get capabilities");
let w = caps
.by_index()
.map(|(_, ac)| ac.name.len())
.max()
.unwrap_or(0);
for (_, ac) in caps.by_index() {
println!("{:#w$}", ac);
}
}