6 use std::process::exit;
7 use std::env::current_dir;
8 use std::fs::{create_dir_all, remove_dir_all};
10 use crate::file_finder::find_files;
11 use crate::file_handler::FileHandler;
13 fn main() -> Result<()> {
14 let source = current_dir()?;
15 let source_name = source.file_name().unwrap().to_string_lossy();
16 let parent = source.parent().unwrap();
17 let gemini_destination_name = format!("{}_gemini", source_name);
18 let gemini_destination = parent.join(gemini_destination_name);
19 let html_destination_name = format!("{}_html", source_name);
20 let html_destination = parent.join(html_destination_name);
22 // Step 1. Identify the files
23 let files = find_files(&source);
25 // Step 2. Prepare the target priority
26 match remove_dir_all(&html_destination) {
29 create_dir_all(&html_destination)?;
30 match remove_dir_all(&gemini_destination) {
33 create_dir_all(&gemini_destination)?;
35 // Step 3. Load the layout
36 let mut file_handler = FileHandler::default();
37 match file_handler.get_layout_or_panic(&files) {
40 eprintln!("{}", error);
45 // Step 4. Process all files
46 file_handler.handle_all(&source, &html_destination, &gemini_destination, &files);