1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use confyg::Confygery;
use super::{init, schema};
pub fn load(config_file: String, log_level: String) -> schema::Config {
let defaults = schema::defaults();
match init::config(config_file.clone()) {
Ok(_) => (),
Err(e) => panic!("{}", e),
}
match Confygery::new()
.add_file(&config_file)
.add_struct(&defaults)
.build::<schema::Config>()
{
Ok(mut cfg) => {
if !log_level.is_empty() {
cfg.logging.level = log_level;
}
cfg.rucksack.cfg_file = config_file;
cfg
}
Err(e) => panic!("{}", e),
}
}