archive
/
md-pdf-rs
Archived
1
Fork 0

Store input files as paths

This commit is contained in:
Jake Howard 2017-07-18 13:39:31 +01:00
parent 5b0bf034c7
commit 7c82aa6623
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
use serde_yaml;
use serde_yaml::Value;
use std::path::PathBuf;
pub mod read;
pub mod validate;
@ -7,14 +8,14 @@ pub mod consts;
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Config {
input: Vec<String>,
input: Vec<PathBuf>,
}
impl Config {
fn new(raw: Value) -> Config {
return Config {
input: read::get_inputs(raw),
input: read::get_input_files(raw),
..Default::default()
};
}

View File

@ -22,7 +22,8 @@ pub fn read() -> String {
}
pub fn get_inputs(conf: Value) -> Vec<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| x.as_str().unwrap().to_string()).collect();
return input_values.into_iter().map(|x| working_dir.join(x.as_str().unwrap().to_string())).collect();
}