starting config.yaml
This commit is contained in:
parent
bfeae64c84
commit
d79924f70a
2
config.yaml
Normal file
2
config.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
links:
|
||||
source: data/links.yaml
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
src/main.rs
27
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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user