Tholp's bespoke website generator

Check parent folders for project file if missing

Tholp1 3a16cd22 55632975

+38 -1
+27 -1
src/main.rs
··· 10 10 env, 11 11 fs::{self, File}, 12 12 io::Write, 13 + path::PathBuf, 13 14 process::{exit, Output}, 14 15 }; 15 16 use stringtools::{ ··· 21 22 static DELIMITERS: [char; 10] = [' ', '\n', '\t', '(', ')', '{', '}', '\\', '\'', '\"']; 22 23 23 24 fn main() { 24 - let mut project = parse_project(env::current_dir().unwrap().as_path()); 25 + let mut project_folder = PathBuf::from(env::current_dir().unwrap().as_path()); 26 + 27 + let mut project_path = project_folder.clone(); 28 + project_path.push("skidmark.toml"); 29 + 30 + while !project_path.exists() || project_path.is_dir() { 31 + let ok = project_folder.pop(); 32 + if !ok { 33 + println!("No skidmark.toml project file found in this folder or ancestors."); 34 + exit(1); 35 + } 36 + project_path = project_folder.clone(); 37 + project_path.push("skidmark.toml"); 38 + } 39 + println!("Operatting with {:?}", &project_path.as_os_str()); 40 + assert!(env::set_current_dir(&project_folder).is_ok()); 41 + 42 + let mut project = parse_project(&project_path); 43 + 44 + let mut num = 0; 45 + 46 + for group in &project.filegroups { 47 + num = num + group.files.len(); 48 + } 49 + 50 + println!("Proccesing {} files.", num); 25 51 for group in &mut project.filegroups { 26 52 for infile in &mut group.files { 27 53 process_file(infile, &mut project.context);
+11
src/projectparse.rs
··· 32 32 33 33 pub struct ProjectContext { 34 34 pub filemap: Vec<PathBuf>, // mapped to index 35 + //variables later 35 36 } 36 37 37 38 macro_rules! get_table_bool_or_default { ··· 147 148 let mut new_file = crate::types::InputFile::new(); 148 149 new_file.file_input = project.settings.input_folder.clone(); 149 150 new_file.file_input.push(filename); 151 + 152 + new_file.file_htmlout = project.settings.output_folder.clone(); 153 + new_file.file_htmlout.push(filename); 154 + new_file.file_htmlout.set_extension("html"); 155 + 156 + new_file.file_skidout = new_file.file_htmlout.clone(); 157 + new_file.file_skidout.set_extension("sko"); 158 + 150 159 group.files.push(new_file); 151 160 } 152 161 } 162 + 163 + project.filegroups.push(group); 153 164 } 154 165 155 166 return project;