From db2baf3fa0a38780a1889f08ad327d5f5026cf38 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 19 Jul 2017 19:40:01 +0100 Subject: [PATCH] Add function to get output files --- src/config/mod.rs | 1 + src/config/read.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/config/mod.rs b/src/config/mod.rs index 6485cbc..e85c2b1 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -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); } diff --git a/src/config/read.rs b/src/config/read.rs index 4c506f4..e95fc74 100644 --- a/src/config/read.rs +++ b/src/config/read.rs @@ -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 { .map(|x| working_dir.join(x.as_str().unwrap().to_string())) .collect(); } + + +pub fn get_output_files(conf: &Value) -> HashMap { + let working_dir = current_dir().unwrap(); + let output_raw = conf.get("output").unwrap().as_mapping().unwrap(); + let mut output_map : HashMap = 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; +}