Format
This commit is contained in:
parent
c62e229dfd
commit
79e6c7cfcc
3 changed files with 9 additions and 10 deletions
|
@ -36,20 +36,16 @@ 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get_output_files(conf: &Value) -> HashMap<String, PathBuf> {
|
pub fn get_output_files(conf: &Value) -> HashMap<String, PathBuf> {
|
||||||
let working_dir = current_dir().unwrap();
|
let working_dir = current_dir().unwrap();
|
||||||
let output_raw = conf.get("output").unwrap().as_mapping().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() {
|
for output in output_raw.into_iter() {
|
||||||
output_map.insert(to_string(output.0), working_dir.join(to_string(output.1)));
|
output_map.insert(to_string(output.0), working_dir.join(to_string(output.1)));
|
||||||
}
|
}
|
||||||
return output_map;
|
return output_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue