aboutsummaryrefslogtreecommitdiff
path: root/src/command/status/blog_status.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-04-06 00:57:56 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-04-06 00:57:56 +0200
commitd0f582b98712d967b2f95d0405886d063bd89468 (patch)
treecc644c21278d336772557366bcdd3e46b22065db /src/command/status/blog_status.rs
parent8b3b94a38b443c50afc5b42cca45db7c18ce280d (diff)
Get stricter clippy
Diffstat (limited to 'src/command/status/blog_status.rs')
-rw-r--r--src/command/status/blog_status.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/command/status/blog_status.rs b/src/command/status/blog_status.rs
index 48f608a..3f42f32 100644
--- a/src/command/status/blog_status.rs
+++ b/src/command/status/blog_status.rs
@@ -1,19 +1,26 @@
use crate::configuration::Configuration;
+use std::fmt::Write;
use std::fs::read_dir;
+use std::io::{Error, ErrorKind, Result};
use std::path::PathBuf;
-pub fn status(configuration: &Configuration) -> String {
+pub fn status(configuration: &Configuration) -> Result<String> {
let mut status_message = String::new();
status_message.push_str("# Blog\n");
// Main Configuration Locations
let blog_count = count_entries(&configuration.posts_directory);
- status_message.push_str(&format!("Number of posts in blog: {blog_count}\n"));
+ writeln!(&mut status_message, "Number of posts in blog: {blog_count}")
+ .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
let archive_count = count_entries(&configuration.archive_directory);
- status_message.push_str(&format!("Number of posts in archive: {archive_count}\n"));
- status_message
+ writeln!(
+ &mut status_message,
+ "Number of posts in archive: {archive_count}"
+ )
+ .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
+ Ok(status_message)
}
fn count_entries(path: &PathBuf) -> String {