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("# Blog\n");
10 // Main Configuration Locations
11 let blog_count = count_entries(&configuration.posts_directory);
12 status_message.push_str(&format!("Number of posts in blog: {}\n", blog_count));
14 let archive_count = count_entries(&configuration.archive_directory);
15 status_message.push_str(&format!("Number of posts in archive: {}\n", archive_count));
19 fn count_entries(path: &PathBuf) -> String {
20 match read_dir(path) {
21 Ok(entries) => entries.filter_map(Result::ok).count().to_string(),
22 Err(_) => "0".to_string()