use std::{fs, path::PathBuf};
use crate::templates::css::write_css_to_file;
pub struct Init;
impl Init {
pub fn run(&self, path: &str) -> crate::BlogResult<()> {
let posts_path = PathBuf::from(path).join("posts");
let static_path = PathBuf::from(path).join("static");
fs::create_dir_all(posts_path)
.map_err(|e| crate::BlogError::io(e, "Unable to create posts directory".to_string()))?;
fs::create_dir_all(&static_path).map_err(|e| {
crate::BlogError::io(e, "Unable to create static directory".to_string())
})?;
write_css_to_file(static_path.join("styles.css"))?;
println!("Created blog-rs directory at {path:?}");
Ok(())
}
}