Tholp's bespoke website generator

Unquote filenames in console output, wip args

Tholp1 636dfb9b 874303c2

Changed files
+75 -10
src
+2 -2
Cargo.toml
···
[package]
name = "skidmark"
-
version = "0.1.0"
+
version = "0.1.0-ALPHA"
edition = "2021"
[dependencies]
chrono = "0.4.41"
+
clap = { version = "4.5.40", features = ["derive"] }
colored = "3.0.0"
glob = "0.3.2"
markdown = "1.0.0"
-
# markdown = {path = "/home/tholp/Desktop/Code/libs/markdown-rs"}
serde = "1.0.218"
toml = "0.8.19"
+45
src/args.rs
···
+
use clap::{Args, Parser, Subcommand};
+
+
#[derive(Parser, Debug)]
+
#[command(version, about, long_about = None)]
+
pub struct ProgramArgs {
+
#[clap(subcommand)]
+
command: Command,
+
+
#[arg(
+
long,
+
default_value_t = false,
+
help = "Console output will not be colored"
+
)]
+
no_color: bool,
+
}
+
+
#[derive(Debug, Subcommand)]
+
enum Command {
+
Init {
+
#[arg(short, long, default_value = ".")]
+
folder: String,
+
},
+
+
Build {
+
#[arg(
+
short = 'f',
+
long,
+
default_value = "",
+
value_name = "PROJECT FILE",
+
help = "Override skidmark.toml"
+
)]
+
project_file: String,
+
},
+
+
Clean {
+
#[arg(
+
short = 'f',
+
long,
+
default_value = "",
+
value_name = "PROJECT FILE",
+
help = "Override skidmark.toml"
+
)]
+
project_file: String,
+
},
+
}
+15 -6
src/console.rs
···
pub fn error_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) {
println!(
-
"{} {:?}:{}; {}",
+
"{} {}:{}; {}",
"[ERROR]".red(),
context
.file_for_index(origin_index)
-
.expect("Panic in the error func.... (file_for_index() was None!)"),
+
.expect("Panic in the error func.... (file_for_index() was None!)")
+
.into_os_string()
+
.into_string()
+
.unwrap(),
origin_line,
msg
);
···
pub fn warn_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) {
println!(
-
"{} {:?}:{}; {}",
+
"{} {}:{}; {}",
"[WARN]".yellow(),
context
.file_for_index(origin_index)
-
.expect("Panic in the warn func.... (file_for_index() was None!)"),
+
.expect("Panic in the warn func.... (file_for_index() was None!)")
+
.into_os_string()
+
.into_string()
+
.unwrap(),
origin_line,
msg
);
···
msg: &String,
) {
println!(
-
"{} {:?}:{}; {}",
+
"{} {}:{}; {}",
"[REMINDER]".cyan(),
context
.file_for_index(origin_index)
-
.expect("Panic in the warn func.... (file_for_index() was None!)"),
+
.expect("Panic in the warn func.... (file_for_index() was None!)")
+
.into_os_string()
+
.into_string()
+
.unwrap(),
origin_line,
msg
);
+13 -2
src/main.rs
···
+
mod args;
mod console;
mod macros;
mod project;
mod stringtools;
mod types;
+
use clap::Parser;
use console::*;
use macros::MACRO_LIST;
use markdown::{CompileOptions, Constructs, Options, ParseOptions};
···
use stringtools::{collect_arguments, collect_block, split_to_tokens, trim_whitespace_tokens};
use types::{InputFile, Token};
-
use crate::types::Expand;
+
use crate::{args::ProgramArgs, types::Expand};
static DELIMITERS: &'static [char] = &[
' ', '\n', '\t', '(', ')', '{', '}', '[', ']', '<', '>', '\\', '\'', '\"', ';',
];
fn main() {
+
// let args = ProgramArgs::parse();
+
let mut project_folder = PathBuf::from(env::current_dir().unwrap().as_path());
let mut project_path = project_folder.clone();
···
skid_output += &t.contents;
}
+
let mut folder = file.file_skidout.clone();
+
folder.pop();
+
if fs::create_dir_all(&folder).is_err() {
+
error_generic(&format!("Could not make the folder {:?}", &folder));
+
}
+
if convert_html {
fs::write(&file.file_skidout, &skid_output).expect("Couldn't write skid to file");
···
parse: ParseOptions {
constructs: Constructs {
code_indented: false,
+
//html_flow: false,
..Constructs::gfm()
},
···
fs::write(&file.file_out, &skid_output).expect("Couldn't write output to file");
}
ok_generic(&format!(
-
"\"{}\" written \n\n",
+
"{} written \n\n",
file.file_out
.to_str()
.unwrap_or("Couldnt Unwrap file_out name")