Tholp's bespoke website generator
0
fork

Configure Feed

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

Unquote filenames in console output, wip args

Tholp1 636dfb9b 874303c2

+75 -10
+2 -2
Cargo.toml
··· 1 1 [package] 2 2 name = "skidmark" 3 - version = "0.1.0" 3 + version = "0.1.0-ALPHA" 4 4 edition = "2021" 5 5 6 6 [dependencies] 7 7 chrono = "0.4.41" 8 + clap = { version = "4.5.40", features = ["derive"] } 8 9 colored = "3.0.0" 9 10 glob = "0.3.2" 10 11 markdown = "1.0.0" 11 - # markdown = {path = "/home/tholp/Desktop/Code/libs/markdown-rs"} 12 12 serde = "1.0.218" 13 13 toml = "0.8.19"
+45
src/args.rs
··· 1 + use clap::{Args, Parser, Subcommand}; 2 + 3 + #[derive(Parser, Debug)] 4 + #[command(version, about, long_about = None)] 5 + pub struct ProgramArgs { 6 + #[clap(subcommand)] 7 + command: Command, 8 + 9 + #[arg( 10 + long, 11 + default_value_t = false, 12 + help = "Console output will not be colored" 13 + )] 14 + no_color: bool, 15 + } 16 + 17 + #[derive(Debug, Subcommand)] 18 + enum Command { 19 + Init { 20 + #[arg(short, long, default_value = ".")] 21 + folder: String, 22 + }, 23 + 24 + Build { 25 + #[arg( 26 + short = 'f', 27 + long, 28 + default_value = "", 29 + value_name = "PROJECT FILE", 30 + help = "Override skidmark.toml" 31 + )] 32 + project_file: String, 33 + }, 34 + 35 + Clean { 36 + #[arg( 37 + short = 'f', 38 + long, 39 + default_value = "", 40 + value_name = "PROJECT FILE", 41 + help = "Override skidmark.toml" 42 + )] 43 + project_file: String, 44 + }, 45 + }
+15 -6
src/console.rs
··· 11 11 12 12 pub fn error_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) { 13 13 println!( 14 - "{} {:?}:{}; {}", 14 + "{} {}:{}; {}", 15 15 "[ERROR]".red(), 16 16 context 17 17 .file_for_index(origin_index) 18 - .expect("Panic in the error func.... (file_for_index() was None!)"), 18 + .expect("Panic in the error func.... (file_for_index() was None!)") 19 + .into_os_string() 20 + .into_string() 21 + .unwrap(), 19 22 origin_line, 20 23 msg 21 24 ); ··· 28 31 29 32 pub fn warn_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) { 30 33 println!( 31 - "{} {:?}:{}; {}", 34 + "{} {}:{}; {}", 32 35 "[WARN]".yellow(), 33 36 context 34 37 .file_for_index(origin_index) 35 - .expect("Panic in the warn func.... (file_for_index() was None!)"), 38 + .expect("Panic in the warn func.... (file_for_index() was None!)") 39 + .into_os_string() 40 + .into_string() 41 + .unwrap(), 36 42 origin_line, 37 43 msg 38 44 ); ··· 49 55 msg: &String, 50 56 ) { 51 57 println!( 52 - "{} {:?}:{}; {}", 58 + "{} {}:{}; {}", 53 59 "[REMINDER]".cyan(), 54 60 context 55 61 .file_for_index(origin_index) 56 - .expect("Panic in the warn func.... (file_for_index() was None!)"), 62 + .expect("Panic in the warn func.... (file_for_index() was None!)") 63 + .into_os_string() 64 + .into_string() 65 + .unwrap(), 57 66 origin_line, 58 67 msg 59 68 );
+13 -2
src/main.rs
··· 1 + mod args; 1 2 mod console; 2 3 mod macros; 3 4 mod project; 4 5 mod stringtools; 5 6 mod types; 6 7 8 + use clap::Parser; 7 9 use console::*; 8 10 use macros::MACRO_LIST; 9 11 use markdown::{CompileOptions, Constructs, Options, ParseOptions}; ··· 16 18 use stringtools::{collect_arguments, collect_block, split_to_tokens, trim_whitespace_tokens}; 17 19 use types::{InputFile, Token}; 18 20 19 - use crate::types::Expand; 21 + use crate::{args::ProgramArgs, types::Expand}; 20 22 21 23 static DELIMITERS: &'static [char] = &[ 22 24 ' ', '\n', '\t', '(', ')', '{', '}', '[', ']', '<', '>', '\\', '\'', '\"', ';', 23 25 ]; 24 26 25 27 fn main() { 28 + // let args = ProgramArgs::parse(); 29 + 26 30 let mut project_folder = PathBuf::from(env::current_dir().unwrap().as_path()); 27 31 28 32 let mut project_path = project_folder.clone(); ··· 268 272 skid_output += &t.contents; 269 273 } 270 274 275 + let mut folder = file.file_skidout.clone(); 276 + folder.pop(); 277 + if fs::create_dir_all(&folder).is_err() { 278 + error_generic(&format!("Could not make the folder {:?}", &folder)); 279 + } 280 + 271 281 if convert_html { 272 282 fs::write(&file.file_skidout, &skid_output).expect("Couldn't write skid to file"); 273 283 ··· 287 297 parse: ParseOptions { 288 298 constructs: Constructs { 289 299 code_indented: false, 300 + 290 301 //html_flow: false, 291 302 ..Constructs::gfm() 292 303 }, ··· 300 311 fs::write(&file.file_out, &skid_output).expect("Couldn't write output to file"); 301 312 } 302 313 ok_generic(&format!( 303 - "\"{}\" written \n\n", 314 + "{} written \n\n", 304 315 file.file_out 305 316 .to_str() 306 317 .unwrap_or("Couldnt Unwrap file_out name")