This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf-rs/src/config/mod.rs

30 lines
603 B
Rust
Raw Normal View History

2017-07-17 09:52:22 +01:00
use serde_yaml;
2017-07-18 09:20:39 +01:00
use serde_yaml::Value;
2017-07-17 09:52:22 +01:00
pub mod read;
pub mod validate;
2017-07-17 09:59:54 +01:00
pub mod consts;
2017-07-17 09:52:22 +01:00
2017-07-18 09:20:39 +01:00
#[derive(Debug, Serialize, Deserialize, Default)]
2017-07-17 09:52:22 +01:00
pub struct Config {
2017-07-18 09:20:39 +01:00
input: Vec<String>,
2017-07-17 09:52:22 +01:00
}
impl Config {
2017-07-18 09:40:03 +01:00
fn new(raw: Value) -> Config {
2017-07-18 09:20:39 +01:00
return Config {
2017-07-18 09:40:03 +01:00
input: read::get_inputs(raw),
2017-07-18 09:20:39 +01:00
..Default::default()
};
2017-07-17 14:53:18 +01:00
}
2017-07-17 09:52:22 +01:00
}
2017-07-18 09:20:39 +01:00
pub fn get_config() -> Config {
2017-07-17 09:52:22 +01:00
let config_str = read::read();
2017-07-18 09:40:03 +01:00
let config_value: Value = serde_yaml::from_str(&config_str).unwrap();
validate::validate(&config_value).expect("Validation Error");
return Config::new(config_value);
2017-07-17 09:52:22 +01:00
}