2 use std::path::PathBuf;
3 use crate::configuration::Configuration;
5 pub fn status(configuration: &Configuration) -> String {
6 let mut status_message = String::new();
8 status_message.push_str("# Configuration\n");
9 status_message.push_str("\n## Directories\n");
11 // Main Configuration Locations
12 status_message.push_str(&get_directory_stats("Configuration", &configuration.config_directory));
13 status_message.push_str(&get_directory_stats("Data", &configuration.data_directory));
14 status_message.push_str(&get_directory_stats("Output", &configuration.output_directory));
16 status_message.push_str("\n## Blog Settings\n");
17 status_message.push_str(&format!("Number of posts to keep: {}\n", configuration.max_posts));
21 fn get_directory_stats(label: &str, directory: &PathBuf) -> String {
22 let mut status_message = String::new();
24 status_message.push_str(&format!("{}: {}. ", label, directory.display()));
25 if directory.exists() {
26 status_message.push_str("Exists ");
27 if fs::read_dir(&directory).is_ok() {
28 status_message.push_str("and is readable.\n");
30 status_message.push_str("but is not readable.\n");
33 status_message.push_str("Does not exist.\n");