use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;
use walkdir::WalkDir;
pub fn get_templates(template: String) -> HashMap<String, String> {
let template_path = PathBuf::from_str(&template);
let mut templates: HashMap<String, String> = HashMap::new();
for path in WalkDir::new(template_path.unwrap()).into_iter().filter_map(|e| e.ok()) {
if path.metadata().unwrap().is_file() {
let relative_path = PathBuf::from(path.path());
let relative_path = relative_path.strip_prefix(&template).unwrap();
let full_path = path.path().display().to_string();
if let Ok(file) = std::fs::read_to_string(&full_path) {
templates.insert(relative_path.to_str().unwrap_or_default().to_string(), file);
}
}
}
templates
}