diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..e22a6be --- /dev/null +++ b/config.yaml @@ -0,0 +1,2 @@ +links: + source: data/links.yaml \ No newline at end of file diff --git a/src/file_utils.rs b/src/file_utils.rs index 5465a8c..9338877 100644 --- a/src/file_utils.rs +++ b/src/file_utils.rs @@ -31,7 +31,8 @@ pub fn create_dirs(dirs: &[&str]) { for dir in dirs { let path = format!("./public/{}", dir); if !Path::new(&path).exists() { - fs::create_dir(&path).expect("Could not create public directory"); + let err = format!("Could not create {} directory", path); + fs::create_dir(&path).expect(&err); } } diff --git a/src/main.rs b/src/main.rs index 3b98c03..4f3cbb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,33 @@ mod links; mod file_utils; use crate::links::{load_links,render_links}; +use serde::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct LinksConfig { + source: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct BlogConfig { + source: String, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct Config { + links: Option(LinksConfig), + blog: Option(BlogConfig), +} + +fn load_config() { + let config_file = std::fs::File::open("./config.yaml").expect("Could not find config.yaml file"); + + let config: Config = serde_yaml::from_reader(config_file).expect("Could not read values"); + println!("{:?}", config) + +} + fn main() { // absolutely destroy any /public data, so we have a clean slate to write to file_utils::delete_public_dir(); @@ -16,4 +41,6 @@ fn main() { let links_output = render_links(links_input); file_utils::write_file(links_output); + + load_config(); }