use config::{Config, File};
use glob::glob;
use std::collections::HashMap;
use std::path::Path;
fn main() {
let settings = Config::builder()
.add_source(File::with_name("examples/glob/conf/00-default.toml"))
.add_source(File::from(Path::new("examples/glob/conf/05-some.yml")))
.add_source(File::from(Path::new("examples/glob/conf/99-extra.json")))
.build()
.unwrap();
println!(
"\n{:?} \n\n-----------",
settings
.try_deserialize::<HashMap<String, String>>()
.unwrap()
);
let settings = Config::builder()
.add_source(vec![
File::with_name("examples/glob/conf/00-default.toml"),
File::from(Path::new("examples/glob/conf/05-some.yml")),
File::from(Path::new("examples/glob/conf/99-extra.json")),
])
.build()
.unwrap();
println!(
"\n{:?} \n\n-----------",
settings
.try_deserialize::<HashMap<String, String>>()
.unwrap()
);
let settings = Config::builder()
.add_source(
glob("examples/glob/conf/*")
.unwrap()
.map(|path| File::from(path.unwrap()))
.collect::<Vec<_>>(),
)
.build()
.unwrap();
println!(
"\n{:?} \n\n-----------",
settings
.try_deserialize::<HashMap<String, String>>()
.unwrap()
);
}