Confindent
Configuration by indentation. Read the spec inspired by
the format of the ssh client configuration commonly found on Linux machines
at ~/.ssh/config
.
Read configuration from a file
extern crate confindent;
use confindent::{ConfParent, Confindent};
fn main() {
let conf = Confindent::from_file("examples/example.conf").unwrap();
let host = conf.child("Host").unwrap();
let hostname: String = host.get().unwrap();
let username: String = host.child_value("Username").unwrap();
let password: String = host.child_value("Password").unwrap();
println!("ssh {}@{} -p {}", username, hostname, password);
}
Write cconfiguration to a file
extern crate confindent;
use confindent::{ConfParent, Confindent};
fn main() {
let mut conf = Confindent::new();
conf.create("Host", "example.net").create("Idle", "3600");
conf.child_mut("Host")
.unwrap()
.create("Username", "gerald")
.create("Password", "qwerty");
conf.to_file("example.conf").unwrap();
}