ssh_cfg/lib.rs
1#![deny(missing_docs)]
2
3//! Parses `~/.ssh/config` asynchronously.
4//!
5//! ```rust
6//! use ssh_cfg::{SshConfigParser, SshOptionKey};
7//! use tokio::runtime;
8//!
9//! async fn parse_ssh_config() -> Result<(), Box<dyn std::error::Error>> {
10//! let ssh_config = SshConfigParser::parse_home().await?;
11//!
12//! // Print first host config
13//! if let Some((first_host, host_config)) = ssh_config.iter().next() {
14//! println!("Host: {}", first_host);
15//!
16//! // Print its configured SSH key if any
17//! if let Some(identity_file) = host_config.get(&SshOptionKey::IdentityFile) {
18//! println!(" {} {}", SshOptionKey::IdentityFile, identity_file);
19//! }
20//! }
21//!
22//! // Print all host configs
23//! println!();
24//! println!("{:#?}", ssh_config);
25//!
26//! Ok(())
27//! }
28//!
29//! fn main() -> Result<(), Box<dyn std::error::Error>> {
30//! let rt = runtime::Builder::new_current_thread().build()?;
31//! rt.block_on(parse_ssh_config())
32//! }
33//! ```
34//!
35//! Currently values are stored as `String`s. Ideally we would parse them into a
36//! strong data model.
37
38pub use crate::{
39 config_error::ConfigError, error::Error, ssh_config::SshConfig,
40 ssh_config_parser::SshConfigParser, ssh_host_config::SshHostConfig,
41 ssh_option_key::SshOptionKey,
42};
43
44mod config_error;
45mod error;
46mod ssh_config;
47mod ssh_config_parser;
48mod ssh_host_config;
49mod ssh_option_key;