]>
Commit | Line | Data |
---|---|---|
8d4fac52 | 1 | mod gemini_parser; |
1e2d00b6 RBR |
2 | mod file_finder; |
3 | mod file_handler; | |
4 | ||
4fd89b80 | 5 | use std::io::Result; |
1e2d00b6 | 6 | use std::env::current_dir; |
ea529736 | 7 | use std::fs::{create_dir_all, remove_dir_all}; |
8d4fac52 | 8 | |
1e2d00b6 | 9 | use crate::file_finder::find_files; |
4fd89b80 | 10 | use crate::file_handler::FileHandler; |
8d4fac52 | 11 | |
4fd89b80 | 12 | fn main() -> Result<()> { |
4fd89b80 RBR |
13 | let source = current_dir()?; |
14 | let source_name = source.file_name().unwrap().to_string_lossy(); | |
15 | let parent = source.parent().unwrap(); | |
16 | let destination_name = format!("{}_html", source_name); | |
17 | let destination = parent.join(destination_name); | |
18 | ||
19 | // Step 1. Identify the files | |
20 | let files = find_files(&source); | |
21 | ||
22 | // Step 2. Prepare the target priority | |
ea529736 RBR |
23 | match remove_dir_all(&destination) { |
24 | _ => {} | |
25 | }; | |
4fd89b80 RBR |
26 | create_dir_all(&destination)?; |
27 | ||
1e2d00b6 | 28 | println!("Found {} files", files.len()); |
4fd89b80 RBR |
29 | |
30 | // Step 3. Load the layout | |
31 | let mut file_handler = FileHandler::default(); | |
32 | file_handler.get_layout_or_panic(&files); | |
33 | ||
34 | // Step 4. Process all files | |
35 | file_handler.handle_all(&source, &destination, &files); | |
36 | Ok(()) | |
8d4fac52 | 37 | } |