use ssh_cfg::{SshConfigParser, SshOptionKey};
use tokio::runtime;
async fn parse_ssh_config() -> Result<(), Box<dyn std::error::Error>> {
let ssh_config = SshConfigParser::parse_home().await?;
if let Some((first_host, host_config)) = ssh_config.iter().next() {
println!("Host: {}", first_host);
if let Some(identity_file) = host_config.get(&SshOptionKey::IdentityFile) {
println!(" {} {}", SshOptionKey::IdentityFile, identity_file);
}
}
println!();
println!("{:#?}", ssh_config);
Ok(())
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rt = runtime::Builder::new_current_thread().build()?;
rt.block_on(parse_ssh_config())
}