2 use std::path::PathBuf;
3 use crate::configuration::Configuration;
5 pub fn status() -> String {
6 let configuration = Configuration::new();
7 let mut status_message = String::new();
9 status_message.push_str("# Configuration\n");
10 status_message.push_str("## Directories\n");
12 // Main Configuration Locations
13 status_message.push_str(&get_directory_stats("Configuration", configuration.config_directory));
14 status_message.push_str(&get_directory_stats("Data", configuration.data_directory));
15 status_message.push_str(&get_directory_stats("Output", configuration.output_directory));
17 status_message.push_str("## Blog Settings\n");
18 status_message.push_str(&format!("Number of posts to keep: {}\n", configuration.max_posts));
22 fn get_directory_stats(label: &str, directory: PathBuf) -> String {
23 let mut status_message = String::new();
25 status_message.push_str(&format!("{}: {}\n", label, directory.display()));
26 if directory.exists() {
27 status_message.push_str(&format!("{} directory exists.\n", label));
28 if fs::read_dir(&directory).is_ok() {
29 status_message.push_str(&format!("{} directory is readable.\n", label));
31 status_message.push_str(&format!("{} directory is not readable.\n", label));
34 status_message.push_str(&format!("{} directory does not exist.\n", label));