4 use std::env::current_dir;
5 use std::fs::{create_dir_all, remove_dir_all};
7 use std::process::exit;
9 use crate::file_finder::find_files;
10 use crate::file_handler::FileHandler;
12 fn main() -> Result<()> {
13 let source = current_dir()?;
14 let source_name = source.file_name().unwrap().to_string_lossy();
15 let parent = source.parent().unwrap();
16 let gemini_destination_name = format!("{source_name}_gemini");
17 let gemini_destination = parent.join(gemini_destination_name);
18 let html_destination_name = format!("{source_name}_html");
19 let html_destination = parent.join(html_destination_name);
21 // Step 1. Identify the files
22 let files = find_files(&source);
24 // Step 2. Load the layout
25 let mut file_handler = FileHandler::default();
26 match file_handler.get_layout_or_panic(&files) {
34 // Step 3. Prepare the target priority
35 let _ = remove_dir_all(&html_destination);
36 let _ = remove_dir_all(&gemini_destination);
38 create_dir_all(&html_destination).expect("Could not create HTML directory.");
39 create_dir_all(&gemini_destination).expect("Could not create Gemini directory.");
41 // Step 4. Process all files
42 file_handler.handle_all(&source, &html_destination, &gemini_destination, &files);