archive
/
md-pdf-rs
Archived
1
Fork 0

Add function to get output files

This commit is contained in:
Jake Howard 2017-07-19 19:40:01 +01:00
parent 37566249a7
commit db2baf3fa0
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 13 additions and 0 deletions

View File

@ -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);
}

View File

@ -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;
}