mod content; mod contenttype; mod syntax; pub use content::Content; pub use contenttype::ContentType; pub use syntax::system; use anyhow::{Context, Result}; use walkdir::WalkDir; pub fn load_content_dir(path: &str) -> Result { let mut raw_content = Vec::new(); for e in WalkDir::new(path).into_iter().filter_map(|e| e.ok()) { if e.metadata().unwrap().is_file() { // TODO: better warnings match e.path().extension() { Some(t) => { if t.to_str() != Some("toml") { println!("[WARNING] {e:#?} is not a toml file, skipping."); continue; } } None => { println!("[WARNING] {e:#?} is not a toml file, skipping."); continue; } } let c = crate::content::ContentType::from_path(e.path()) .with_context(|| format!("Could not load {:#?}", e.path()))?; match c { Some(c) => raw_content.push((e.path().to_path_buf(), c)), None => continue, } } } return crate::content::Content::new(raw_content); }