]> git.r.bdr.sh - rbdr/page/blame_incremental - src/main.rs
Use gema_texto for gemini parsing
[rbdr/page] / src / main.rs
... / ...
CommitLineData
1mod file_finder;
2mod file_handler;
3
4use std::env::current_dir;
5use std::fs::{create_dir_all, remove_dir_all};
6use std::io::Result;
7use std::process::exit;
8
9use crate::file_finder::find_files;
10use crate::file_handler::FileHandler;
11
12fn 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);
20
21 // Step 1. Identify the files
22 let files = find_files(&source);
23
24 // Step 2. Load the layout
25 let mut file_handler = FileHandler::default();
26 match file_handler.get_layout_or_panic(&files) {
27 Ok(()) => {}
28 Err(error) => {
29 eprintln!("{error}");
30 exit(1);
31 }
32 }
33
34 // Step 3. Prepare the target priority
35 let _ = remove_dir_all(&html_destination);
36 let _ = remove_dir_all(&gemini_destination);
37
38 create_dir_all(&html_destination).expect("Could not create HTML directory.");
39 create_dir_all(&gemini_destination).expect("Could not create Gemini directory.");
40
41 // Step 4. Process all files
42 file_handler.handle_all(&source, &html_destination, &gemini_destination, &files);
43 Ok(())
44}