Tholp's bespoke website generator
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add !reminder

Tholp1 f9e204bd add4c42d

+66 -46
+22 -5
src/console.rs
··· 4 4 5 5 use crate::projectparse::{FileIndexing, ProjectContext}; 6 6 7 - pub fn error_generic(msg: String) { 7 + pub fn error_generic(msg: &String) { 8 8 println!("{} {}", "[ERROR]".red(), msg); 9 9 exit(1); 10 10 } 11 11 12 - pub fn error_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: String) { 12 + pub fn error_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) { 13 13 println!( 14 14 "{} {:?}:{}; {}", 15 15 "[ERROR]".red(), ··· 22 22 exit(1); 23 23 } 24 24 25 - pub fn warn_generic(msg: String) { 25 + pub fn warn_generic(msg: &String) { 26 26 println!("{} {}", "[WARN]".yellow(), msg); 27 27 } 28 28 29 - pub fn warn_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: String) { 29 + pub fn warn_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) { 30 30 println!( 31 31 "{} {:?}:{}; {}", 32 32 "[WARN]".yellow(), ··· 38 38 ); 39 39 } 40 40 41 - pub fn ok_generic(msg: String) { 41 + pub fn ok_generic(msg: &String) { 42 42 println!("{} {}", "[OK]".green(), msg); 43 43 } 44 + 45 + pub fn reminder_skid( 46 + context: &ProjectContext, 47 + origin_index: usize, 48 + origin_line: usize, 49 + msg: &String, 50 + ) { 51 + println!( 52 + "{} {:?}:{}; {}", 53 + "[REMINDER]".cyan(), 54 + context 55 + .file_for_index(origin_index) 56 + .expect("Panic in the warn func.... (file_for_index() was None!)"), 57 + origin_line, 58 + msg 59 + ); 60 + }
+1 -13
src/macros/insert.rs
··· 19 19 .file_for_index_canonical(origin_index) 20 20 .expect("Macro 'Insert' was given a bad origin index") 21 21 .clone(); 22 - if args.len() != 1 { 23 - error_skid( 24 - context, 25 - origin_index, 26 - origin_line, 27 - format!( 28 - "Insert only accepts 1 argument, got given {} ({:?})", 29 - args.len(), 30 - args 31 - ), 32 - ); 33 - } 34 22 35 23 let mut arg = args[0].clone(); 36 24 let mut search_from_root = arg.starts_with("//"); ··· 65 53 } 66 54 67 55 if !ok { 68 - error_skid(context, origin_index, origin_line, format!("Insert was unable to find the file \"{}\" relative to its origin or in project root.", arg)); 56 + error_skid(context, origin_index, origin_line, &format!("Insert was unable to find the file \"{}\" relative to its origin or in project root.", arg)); 69 57 } 70 58 71 59 let mut output = fs::read_to_string(&include_file).expect("File unreadable or missing");
+9
src/macros/mod.rs
··· 2 2 pub mod simple_blocks; 3 3 pub mod simple_macros; 4 4 pub mod template; 5 + use crate::macros::simple_macros::macro_reminder; 6 + 5 7 use super::types::Macro; 6 8 7 9 use insert::macro_insert; ··· 45 47 has_scope: false, 46 48 min_args: 0, 47 49 max_args: 0, 50 + }, 51 + Macro { 52 + symbol: "reminder", 53 + expansion: macro_reminder, 54 + has_scope: false, 55 + min_args: 1, 56 + max_args: 1, 48 57 }, 49 58 // Scoped 50 59 Macro {
+2 -2
src/macros/simple_blocks.rs
··· 77 77 context, 78 78 origin_index, 79 79 origin_line, 80 - format!( 80 + &format!( 81 81 "Macro `for_each_arg` given block with no \"[[{}..1]]\", intentional?", 82 82 varname 83 83 ), ··· 99 99 100 100 if real_args.len() % replacement_count != 0 { 101 101 error_skid(context, origin_index, origin_line, 102 - format!("`for_each_var` was not given a number of arguments({}) that was a multiple of its replacement posistions({}) (got {:?})", 102 + &format!("`for_each_var` was not given a number of arguments({}) that was a multiple of its replacement posistions({}) (got {:?})", 103 103 real_args.len(), 104 104 replacement_count, 105 105 real_args));
+14 -2
src/macros/simple_macros.rs
··· 4 4 use chrono::Local; 5 5 6 6 use crate::{ 7 - console::error_skid, 7 + console::{error_skid, reminder_skid}, 8 8 projectparse::{FileIndexing, ProjectContext}, 9 9 stringtools::split_to_tokens, 10 10 types::{InputFile, Token}, ··· 38 38 context, 39 39 origin_index, 40 40 origin_line, 41 - format!( 41 + &format!( 42 42 "Time only accepts 1 argument, got given {} ({:?})", 43 43 args.len(), 44 44 args ··· 87 87 origin_index, 88 88 ); 89 89 } 90 + 91 + pub fn macro_reminder( 92 + _file: &mut InputFile, 93 + origin_index: usize, 94 + origin_line: usize, 95 + context: &mut ProjectContext, 96 + args: &Vec<String>, 97 + _scope: &[Token], 98 + ) -> Vec<Token> { 99 + reminder_skid(context, origin_index, origin_line, &args[0]); 100 + Vec::new() 101 + }
+7 -7
src/macros/template.rs
··· 58 58 context, 59 59 origin_index, 60 60 origin_line, 61 - format!( 61 + &format!( 62 62 "Template \"{}\" requires exactly {} arguments, got given {} ({:?})", 63 63 self.symbol, 64 64 self.args.len(), ··· 72 72 context, 73 73 origin_index, 74 74 origin_line, 75 - format!( 75 + &format!( 76 76 "Template \"{}\" requires at least {} arguments, got given {} ({:?})", 77 77 self.symbol, 78 78 self.args.len(), ··· 153 153 context, 154 154 origin_index, 155 155 origin_line, 156 - format!("Attempted template redefinition of \"{}\"", args[0]), 156 + &format!("Attempted template redefinition of \"{}\"", args[0]), 157 157 ); 158 158 } 159 159 } ··· 164 164 context, 165 165 origin_index, 166 166 origin_line, 167 - format!( 167 + &format!( 168 168 "Attempted to make a template using a reserved name \"{}\"", 169 169 args[0] 170 170 ), ··· 178 178 context, 179 179 origin_index, 180 180 origin_line, 181 - format!( 181 + &format!( 182 182 "Attempted to make a template using a reserved parameter name \"{}\"", 183 183 arg 184 184 ), ··· 196 196 context, 197 197 origin_index, 198 198 origin_line, 199 - format!( 199 + &format!( 200 200 "Attempted to make a template with a parameter that contains whitespace \"{}\"", 201 201 param 202 202 ), ··· 209 209 context, 210 210 origin_index, 211 211 origin_line, 212 - format!( 212 + &format!( 213 213 "Template definition of \"{}\" has {} paramters but only uses {}", 214 214 args[0], 215 215 args.len() - 1,
+10 -16
src/main.rs
··· 32 32 let ok = project_folder.pop(); 33 33 if !ok { 34 34 error_generic( 35 - "No skidmark.toml project file found in this folder or ancestors.".into(), 35 + &"No skidmark.toml project file found in this folder or ancestors.".into(), 36 36 ); 37 37 } 38 38 project_path = project_folder.clone(); ··· 126 126 context, 127 127 file.tokens[file.working_index].template_origin, 128 128 file.tokens[file.working_index].line_number, 129 - "Malformed Block".into(), 129 + &"Malformed Block".into(), 130 130 ); 131 131 } 132 132 let block: Vec<Token>; ··· 197 197 context, 198 198 file.tokens[file.working_index].template_origin, 199 199 file.tokens[file.working_index].line_number, 200 - "Malformed Block".into(), 200 + &"Malformed Block".into(), 201 201 ); 202 202 } 203 203 ··· 251 251 context, 252 252 file.tokens[file.working_index].origin_file, 253 253 file.tokens[file.working_index].line_number, 254 - format!( 254 + &format!( 255 255 "Token written as a function but no such function exists \"{}\"", 256 256 file.tokens[file.working_index].contents.trim() 257 257 ), ··· 296 296 ) 297 297 .unwrap(); 298 298 fs::write(&file.file_out, &html_output).expect("Couldn't write output to file"); 299 - ok_generic(format!( 300 - "\"{}\" written \n\n", 301 - file.file_out 302 - .to_str() 303 - .unwrap_or("Couldnt Unwrap file_out name") 304 - )); 305 299 } else { 306 300 fs::write(&file.file_out, &skid_output).expect("Couldn't write output to file"); 307 - ok_generic(format!( 308 - "\"{}\" written \n\n", 309 - file.file_out 310 - .to_str() 311 - .unwrap_or("Couldnt Unwrap file_out name") 312 - )); 313 301 } 302 + ok_generic(&format!( 303 + "\"{}\" written \n\n", 304 + file.file_out 305 + .to_str() 306 + .unwrap_or("Couldnt Unwrap file_out name") 307 + )); 314 308 }
+1 -1
src/types.rs
··· 66 66 scope: &[Token], 67 67 ) -> Vec<Token> { 68 68 if (args.len() > self.max_args) || (args.len() < self.min_args) { 69 - error_skid(context, origin_index, origin_line, format!("Macro \'{}\' was given a number of arguments ({}) not in its acceptable range ({}-{})", 69 + error_skid(context, origin_index, origin_line, &format!("Macro \'{}\' was given a number of arguments ({}) not in its acceptable range ({}-{})", 70 70 self.symbol, args.len(), self.min_args, if self.max_args == usize::max_value() {"No Limit".to_string()} else {format!("{}", self.max_args)})); 71 71 Vec::new() 72 72 } else {