aboutsummaryrefslogtreecommitdiff
path: root/src/command/status
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-07-18 13:22:04 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-07-18 13:22:04 +0200
commit8d11eb64efa67f1d7a6902300fdffd2c7c08df6c (patch)
tree119de904ee30468726d7f58680e1ba47c5dd267e /src/command/status
parent5d8b65a9a5742e5db705cf4c8164138eca20c355 (diff)
Apply clippy and formatting
Diffstat (limited to 'src/command/status')
-rw-r--r--src/command/status/blog_status.rs6
-rw-r--r--src/command/status/configuration_status.rs10
2 files changed, 8 insertions, 8 deletions
diff --git a/src/command/status/blog_status.rs b/src/command/status/blog_status.rs
index 32881d0..cae101a 100644
--- a/src/command/status/blog_status.rs
+++ b/src/command/status/blog_status.rs
@@ -1,7 +1,7 @@
use crate::configuration::Configuration;
use std::fmt::Write;
use std::fs::read_dir;
-use std::io::{Error, ErrorKind, Result};
+use std::io::{Error, Result};
use std::path::PathBuf;
pub fn status(configuration: &Configuration) -> Result<String> {
@@ -12,14 +12,14 @@ pub fn status(configuration: &Configuration) -> Result<String> {
// Main Configuration Locations
let blog_count = count_entries(&configuration.posts_directory);
writeln!(&mut status_message, "Number of posts in blog: {blog_count}")
- .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
+ .map_err(|_| Error::other("Unable to write status"))?;
let archive_count = count_entries(&configuration.archive_directory);
writeln!(
&mut status_message,
"Number of posts in archive: {archive_count}"
)
- .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
+ .map_err(|_| Error::other("Unable to write status"))?;
Ok(status_message)
}
diff --git a/src/command/status/configuration_status.rs b/src/command/status/configuration_status.rs
index 6f7db14..4a01768 100644
--- a/src/command/status/configuration_status.rs
+++ b/src/command/status/configuration_status.rs
@@ -1,7 +1,7 @@
use crate::configuration::Configuration;
use std::fmt::Write;
use std::fs;
-use std::io::{Error, ErrorKind, Result};
+use std::io::{Error, Result};
use std::path::PathBuf;
pub fn status(configuration: &Configuration) -> Result<String> {
@@ -27,7 +27,7 @@ pub fn status(configuration: &Configuration) -> Result<String> {
"Number of posts to keep: {}",
configuration.max_posts
)
- .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
+ .map_err(|_| Error::other("Unable to write status"))?;
Ok(status_message)
}
@@ -35,7 +35,7 @@ fn get_directory_stats(label: &str, directory: &PathBuf) -> Result<String> {
let mut status_message = String::new();
write!(&mut status_message, "{}: {}. ", label, directory.display())
- .map_err(|_| Error::new(ErrorKind::Other, "Unable to write status"))?;
+ .map_err(|_| Error::other("Unable to write status"))?;
if directory.exists() {
status_message.push_str("Exists ");
if fs::read_dir(directory).is_ok() {
@@ -52,7 +52,7 @@ fn get_directory_stats(label: &str, directory: &PathBuf) -> Result<String> {
#[cfg(test)]
mod tests {
- use std::fs::{Permissions, create_dir_all, metadata, set_permissions};
+ use std::fs::{metadata, set_permissions};
use std::path::PathBuf;
#[cfg(unix)]
@@ -61,7 +61,7 @@ mod tests {
#[cfg(windows)]
use std::os::windows::fs::PermissionsExt;
- use crate::configuration::Configuration;
+
use test_utilities::*;