Store input files as paths
This commit is contained in:
parent
5b0bf034c7
commit
7c82aa6623
2 changed files with 6 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
use serde_yaml;
|
use serde_yaml;
|
||||||
use serde_yaml::Value;
|
use serde_yaml::Value;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub mod read;
|
pub mod read;
|
||||||
pub mod validate;
|
pub mod validate;
|
||||||
|
@ -7,14 +8,14 @@ pub mod consts;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Default)]
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
input: Vec<String>,
|
input: Vec<PathBuf>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
fn new(raw: Value) -> Config {
|
fn new(raw: Value) -> Config {
|
||||||
return Config {
|
return Config {
|
||||||
input: read::get_inputs(raw),
|
input: read::get_input_files(raw),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
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();
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue