use std::path::PathBuf;
use crate::configuration::Configuration;
-pub fn status() -> String {
- let configuration = Configuration::new();
+pub fn status(configuration: &Configuration) -> String {
let mut status_message = String::new();
status_message.push_str("# Configuration\n");
- status_message.push_str("## Directories\n");
+ status_message.push_str("\n## Directories\n");
// Main Configuration Locations
- status_message.push_str(&get_directory_stats("Configuration", configuration.config_directory));
- status_message.push_str(&get_directory_stats("Data", configuration.data_directory));
- status_message.push_str(&get_directory_stats("Output", configuration.output_directory));
+ status_message.push_str(&get_directory_stats("Configuration", &configuration.config_directory));
+ status_message.push_str(&get_directory_stats("Data", &configuration.data_directory));
+ status_message.push_str(&get_directory_stats("Output", &configuration.output_directory));
- status_message.push_str("## Blog Settings\n");
+ status_message.push_str("\n## Blog Settings\n");
status_message.push_str(&format!("Number of posts to keep: {}\n", configuration.max_posts));
status_message
}
-fn get_directory_stats(label: &str, directory: PathBuf) -> String {
+fn get_directory_stats(label: &str, directory: &PathBuf) -> String {
let mut status_message = String::new();
- status_message.push_str(&format!("{}: {}\n", label, directory.display()));
+ status_message.push_str(&format!("{}: {}. ", label, directory.display()));
if directory.exists() {
- status_message.push_str(&format!("{} directory exists.\n", label));
+ status_message.push_str("Exists ");
if fs::read_dir(&directory).is_ok() {
- status_message.push_str(&format!("{} directory is readable.\n", label));
+ status_message.push_str("and is readable.\n");
} else {
- status_message.push_str(&format!("{} directory is not readable.\n", label));
+ status_message.push_str("but is not readable.\n");
}
} else {
- status_message.push_str(&format!("{} directory does not exist.\n", label));
+ status_message.push_str("Does not exist.\n");
}
status_message