X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/5f81d796fed4e4efbaf6dbed7d3c69481afddeb3..f7f4335199beaad56d9c962ac84e92a3f78907a6:/src/command/status/configuration_status.rs?ds=sidebyside diff --git a/src/command/status/configuration_status.rs b/src/command/status/configuration_status.rs index 67bf277..6d4e56a 100644 --- a/src/command/status/configuration_status.rs +++ b/src/command/status/configuration_status.rs @@ -2,36 +2,35 @@ use std::fs; 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