diff options
Diffstat (limited to 'src/command')
| -rw-r--r-- | src/command/add_remote.rs | 4 | ||||
| -rw-r--r-- | src/command/publish.rs | 8 | ||||
| -rw-r--r-- | src/command/publish_archive.rs | 8 | ||||
| -rw-r--r-- | src/command/status/blog_status.rs | 6 | ||||
| -rw-r--r-- | src/command/status/configuration_status.rs | 10 |
5 files changed, 18 insertions, 18 deletions
diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs index aa3f745..d22d484 100644 --- a/src/command/add_remote.rs +++ b/src/command/add_remote.rs @@ -1,6 +1,6 @@ use crate::configuration::Configuration; use crate::remote::add; -use std::io::{Error, ErrorKind::Other, Result}; +use std::io::{Error, Result}; pub struct AddRemote; @@ -22,7 +22,7 @@ impl super::Command for AddRemote { _: &str, ) -> Result<()> { let input = input - .ok_or_else(|| Error::new(Other, "You must provide a location for the remote."))?; + .ok_or_else(|| Error::other("You must provide a location for the remote."))?; add( &configuration.config_directory, &configuration.remote_config, diff --git a/src/command/publish.rs b/src/command/publish.rs index 388792f..4b174de 100644 --- a/src/command/publish.rs +++ b/src/command/publish.rs @@ -1,5 +1,5 @@ use crate::configuration::Configuration; -use std::io::{Error, ErrorKind::Other, Result}; +use std::io::{Error, Result}; use std::process::{Command, Stdio}; const COMMAND: &str = "rsync"; @@ -24,14 +24,14 @@ impl super::Command for Publish { _: &str, ) -> Result<()> { let input = input - .ok_or_else(|| Error::new(Other, "You must provide a location to publish the blog"))?; + .ok_or_else(|| Error::other("You must provide a location to publish the blog"))?; Command::new(COMMAND) .arg("--version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .map_err(|_| Error::new(Other, "Publishing requires rsync"))?; + .map_err(|_| Error::other("Publishing requires rsync"))?; Command::new(COMMAND) .arg("-r") @@ -43,7 +43,7 @@ impl super::Command for Publish { .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .map_err(|_| Error::new(Other, "Rsync failed to publish."))?; + .map_err(|_| Error::other("Rsync failed to publish."))?; Ok(()) } diff --git a/src/command/publish_archive.rs b/src/command/publish_archive.rs index 96dda86..289b0c8 100644 --- a/src/command/publish_archive.rs +++ b/src/command/publish_archive.rs @@ -1,5 +1,5 @@ use crate::configuration::Configuration; -use std::io::{Error, ErrorKind::Other, Result}; +use std::io::{Error, Result}; use std::process::{Command, Stdio}; const COMMAND: &str = "rsync"; @@ -24,7 +24,7 @@ impl super::Command for PublishArchive { _: &str, ) -> Result<()> { let input = input.ok_or_else(|| { - Error::new(Other, "You must provide a location to publish the archive") + Error::other("You must provide a location to publish the archive") })?; Command::new(COMMAND) @@ -32,7 +32,7 @@ impl super::Command for PublishArchive { .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .map_err(|_| Error::new(Other, "Publishing requires rsync"))?; + .map_err(|_| Error::other("Publishing requires rsync"))?; Command::new(COMMAND) .arg("-r") @@ -44,7 +44,7 @@ impl super::Command for PublishArchive { .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .map_err(|_| Error::new(Other, "Rsync failed to publish."))?; + .map_err(|_| Error::other("Rsync failed to publish."))?; Ok(()) } 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::*; |