Add struct for storing references data
This commit is contained in:
parent
3066ad2070
commit
823c8bc1ad
|
@ -15,7 +15,14 @@ pub struct Config {
|
||||||
pub input: Vec<PathBuf>,
|
pub input: Vec<PathBuf>,
|
||||||
pub output: HashMap<String, PathBuf>,
|
pub output: HashMap<String, PathBuf>,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub verbosity: u64
|
pub verbosity: u64,
|
||||||
|
pub references: References
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
||||||
|
pub struct References {
|
||||||
|
pub bibliography: PathBuf,
|
||||||
|
pub csl: PathBuf
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
@ -24,6 +31,7 @@ impl Config {
|
||||||
input: read::get_input_files(raw.clone()),
|
input: read::get_input_files(raw.clone()),
|
||||||
output: read::get_output_files(raw.clone()),
|
output: read::get_output_files(raw.clone()),
|
||||||
title: read::get_string(&raw, "title"),
|
title: read::get_string(&raw, "title"),
|
||||||
|
references: read::get_references(raw.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@ use std::io::Read;
|
||||||
use serde_yaml::Value;
|
use serde_yaml::Value;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use config::csl::unpack_csl;
|
||||||
use config::consts;
|
use config::consts;
|
||||||
use utils::result_override;
|
use config::References;
|
||||||
|
use utils::{result_override, resolve_path};
|
||||||
|
|
||||||
fn get_config_path() -> PathBuf {
|
fn get_config_path() -> PathBuf {
|
||||||
let mut working_dir = current_dir().unwrap();
|
let mut working_dir = current_dir().unwrap();
|
||||||
|
@ -55,3 +57,11 @@ pub fn get_output_files(conf: Value) -> HashMap<String, PathBuf> {
|
||||||
}
|
}
|
||||||
return output_map;
|
return output_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_references(config: Value) -> References {
|
||||||
|
let references = config.get("references").unwrap();
|
||||||
|
return References {
|
||||||
|
bibliography: resolve_path(references.get("bibliography").unwrap().as_str().unwrap().into()),
|
||||||
|
csl: unpack_csl(references.get("csl").unwrap().as_str().unwrap().into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in New Issue