]> git.r.bdr.sh - rbdr/page/blame - src/main.rs
Remove clang from page
[rbdr/page] / src / main.rs
CommitLineData
8d4fac52 1mod gemini_parser;
1e2d00b6
RBR
2mod file_finder;
3mod file_handler;
4
4fd89b80 5use std::io::Result;
48ea9080 6use std::process::exit;
1e2d00b6 7use std::env::current_dir;
ea529736 8use std::fs::{create_dir_all, remove_dir_all};
8d4fac52 9
1e2d00b6 10use crate::file_finder::find_files;
4fd89b80 11use crate::file_handler::FileHandler;
8d4fac52 12
4fd89b80 13fn main() -> Result<()> {
4fd89b80
RBR
14 let source = current_dir()?;
15 let source_name = source.file_name().unwrap().to_string_lossy();
16 let parent = source.parent().unwrap();
dd0a540c
RBR
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);
4fd89b80
RBR
21
22 // Step 1. Identify the files
23 let files = find_files(&source);
24
25 // Step 2. Prepare the target priority
dd0a540c 26 match remove_dir_all(&html_destination) {
ea529736
RBR
27 _ => {}
28 };
dd0a540c
RBR
29 create_dir_all(&html_destination)?;
30 match remove_dir_all(&gemini_destination) {
31 _ => {}
32 };
33 create_dir_all(&gemini_destination)?;
4fd89b80 34
4fd89b80
RBR
35 // Step 3. Load the layout
36 let mut file_handler = FileHandler::default();
48ea9080
RBR
37 match file_handler.get_layout_or_panic(&files) {
38 Ok(_) => {},
39 Err(error) => {
40 eprintln!("{}", error);
41 exit(1);
42 }
43 }
4fd89b80
RBR
44
45 // Step 4. Process all files
dd0a540c 46 file_handler.handle_all(&source, &html_destination, &gemini_destination, &files);
4fd89b80 47 Ok(())
8d4fac52 48}