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,10 +36,7 @@ pub fn get_string(conf: &Value, key: &str) -> String {
pub fn get_input_files(conf: &Value) -> Vec<PathBuf> { pub fn get_input_files(conf: &Value) -> Vec<PathBuf> {
let working_dir = current_dir().unwrap(); let working_dir = current_dir().unwrap();
let input_values = conf.get("input").unwrap().as_sequence().unwrap().to_vec(); let input_values = conf.get("input").unwrap().as_sequence().unwrap().to_vec();
return input_values return input_values.into_iter().map(|x| working_dir.join(to_string(&x))).collect();
.into_iter()
.map(|x| working_dir.join(to_string(&x)))
.collect();
} }
@ -52,4 +49,3 @@ pub fn get_output_files(conf: &Value) -> HashMap<String, PathBuf> {
} }
return output_map; return output_map;
} }

View file

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