Add function to get output files
This commit is contained in:
parent
37566249a7
commit
db2baf3fa0
2 changed files with 13 additions and 0 deletions
|
@ -25,5 +25,6 @@ pub fn get_config() -> Config {
|
|||
let config_str = read::read();
|
||||
let config_value: Value = serde_yaml::from_str(&config_str).unwrap();
|
||||
validate::validate(&config_value).expect("Validation Error");
|
||||
read::get_output_files(&config_value);
|
||||
return Config::new(config_value);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::path::PathBuf;
|
|||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use serde_yaml::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use config::consts;
|
||||
|
||||
|
@ -30,3 +31,14 @@ pub fn get_input_files(conf: &Value) -> Vec<PathBuf> {
|
|||
.map(|x| working_dir.join(x.as_str().unwrap().to_string()))
|
||||
.collect();
|
||||
}
|
||||
|
||||
|
||||
pub fn get_output_files(conf: &Value) -> HashMap<String, PathBuf> {
|
||||
let working_dir = current_dir().unwrap();
|
||||
let output_raw = conf.get("output").unwrap().as_mapping().unwrap();
|
||||
let mut output_map : HashMap<String, PathBuf> = HashMap::new();
|
||||
for output in output_raw.into_iter() {
|
||||
output_map.insert(output.0.as_str().unwrap().to_string(), working_dir.join(output.1.as_str().unwrap().to_string()));
|
||||
}
|
||||
return output_map;
|
||||
}
|
||||
|
|
Reference in a new issue