--- /dev/null
+profile = dev
+
+default: build
+
+build:
+ cargo build --profile $(profile)
+
+.PHONY: build
## What happens to files that aren't gemini?
They're copied as-is.
+
+# Building
+
+This project is built using cargo. A makefile is provided to run common tasks.
+
+Build dev version with `make` or `make build`.
+
+Build release with `make -e profile=release` or `make -e profile=release build`.
FileType::Unknown
}
- pub fn get_layout_or_panic(&mut self, files: &Vec<File>) {
+ pub fn get_layout_or_panic(&mut self, files: &Vec<File>) -> Result<(), &str> {
for file in files {
match file.file_type {
FileType::Layout => {
let layout_text = read_to_string(&file.path).unwrap();
self.layout = Some(layout_text);
- return;
+ return Ok(());
},
_ => {}
}
}
- panic!("No layout found. Please ensure there's a _layout.html file at the root");
+ Err("No layout found. Please ensure there's a _layout.html file at the root")
}
pub fn handle_all(&self, source: &PathBuf, destination: &PathBuf, files: &Vec<File>) {
mod file_handler;
use std::io::Result;
+use std::process::exit;
use std::env::current_dir;
use std::fs::{create_dir_all, remove_dir_all};
// Step 3. Load the layout
let mut file_handler = FileHandler::default();
- file_handler.get_layout_or_panic(&files);
+ match file_handler.get_layout_or_panic(&files) {
+ Ok(_) => {},
+ Err(error) => {
+ eprintln!("{}", error);
+ exit(1);
+ }
+ }
// Step 4. Process all files
file_handler.handle_all(&source, &destination, &files);