use std::collections::HashMap;
use tomldir::Config;
fn main() -> tomldir::Result<()> {
println!("--- Loading GitLab Runner Config ---");
let cfg = Config::from_file("examples/example.toml")?;
if let Some(concurrent) = cfg.get_int("concurrent") {
println!("Global concurrency limit: {concurrent}");
}
println!("\n--- Exploring Flattened Keys ---");
let flat: HashMap<String, String> = cfg.flatten_into();
println!("\n[Runner 0: Shell]");
println!("Name: {}", flat.get("runners[0].name").unwrap());
println!("Executor: {}", flat.get("runners[0].executor").unwrap());
println!("\n[Runner 1: Docker]");
println!("Name: {}", flat.get("runners[1].name").unwrap());
println!("Image: {}", flat.get("runners[1].docker.image").unwrap());
println!("\n[Runner 2: SSH]");
println!("Name: {}", flat.get("runners[2].name").unwrap());
println!("Host: {}", flat.get("runners[2].ssh.host").unwrap());
println!("Port: {}", flat.get("runners[2].ssh.port").unwrap());
println!("\n--- Full Flattened Dump (sorted) ---");
let mut keys: Vec<_> = flat.keys().collect();
keys.sort();
for key in keys {
println!("{} = {}", key, flat.get(key).unwrap());
}
Ok(())
}