1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mod input;
mod output;

pub fn get_parent_directory(path: &String) -> String {
    std::path::Path::new(path)
        .parent()
        .expect("Expected file in a directory.")
        .to_str()
        .unwrap()
        .to_string()
}

pub fn read_svd_config(config_path: &String) -> output::Svd {
    let base_conf_path = get_parent_directory(config_path);
    let yaml = input::config::Config::read(&config_path);
    println!(
        "Config read result: {}",
        serde_yaml::to_string(&yaml).unwrap()
    );
    let mut svd = input::svd::Svd::read(base_conf_path + &"/" + yaml.svd.as_str());
    yaml.merge_into(&mut svd);
    svd.to_output()
}