This commit is contained in:
Jake Howard 2017-07-19 21:23:59 +01:00
parent c62e229dfd
commit 79e6c7cfcc
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 9 additions and 10 deletions

View file

@ -36,20 +36,16 @@ pub fn get_string(conf: &Value, key: &str) -> String {
pub fn get_input_files(conf: &Value) -> Vec<PathBuf> {
let working_dir = current_dir().unwrap();
let input_values = conf.get("input").unwrap().as_sequence().unwrap().to_vec();
return input_values
.into_iter()
.map(|x| working_dir.join(to_string(&x)))
.collect();
return input_values.into_iter().map(|x| working_dir.join(to_string(&x))).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();
let mut output_map: HashMap<String, PathBuf> = HashMap::new();
for output in output_raw.into_iter() {
output_map.insert(to_string(output.0), working_dir.join(to_string(output.1)));
}
return output_map;
}

View file

@ -18,7 +18,7 @@ fn check_required_keys(config: &Value) -> ValidationResult {
fn check_input_files(config: &Value) -> ValidationResult {
match config.get("input").unwrap() {
&Value::Sequence(_) => (),
_ => return Err("Input must be sequence".into())
_ => return Err("Input must be sequence".into()),
}
let files = read::get_input_files(config);
@ -33,7 +33,7 @@ fn check_input_files(config: &Value) -> ValidationResult {
fn check_output_files(config: &Value) -> ValidationResult {
match config.get("output").unwrap() {
&Value::Mapping(_) => (),
_ => return Err("Output must be mapping".into())
_ => return Err("Output must be mapping".into()),
}
let files = read::get_output_files(config);
let output_types = vec!["pdf".into()];
@ -64,5 +64,8 @@ pub fn unwrap_group(
pub fn validate(config: &Value) -> ValidationResult {
return unwrap_group(config, vec![&check_required_keys, &check_input_files, &check_output_files]);
return unwrap_group(
config,
vec![&check_required_keys, &check_input_files, &check_output_files]
);
}