X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/606f82c76540a9d80366fdb943c06abe525f662e..c4b892b16fb92c7d89eaee0b1588c52c8836216b:/src/command/update.rs?ds=sidebyside diff --git a/src/command/update.rs b/src/command/update.rs index 3796df2..8a3d6de 100644 --- a/src/command/update.rs +++ b/src/command/update.rs @@ -5,6 +5,7 @@ use super::{sync_down::SyncDown, generate::Generate, sync_up::SyncUp}; use crate::configuration::Configuration; use crate::constants::METADATA_FILENAME; use crate::metadata::Metadata; +use serde_json; pub struct Update; @@ -23,7 +24,7 @@ impl Update { } fn write_metadata(&self, metadata: &Metadata, metadata_location: &PathBuf) -> Result<()> { - let serialized_metadata = metadata.serialize(); + let serialized_metadata = serde_json::to_string(&metadata)?; write(metadata_location, serialized_metadata)?; Ok(()) } @@ -54,7 +55,8 @@ impl super::Command for Update { } fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> { - let input = input.expect("You must provide a path to a post"); + let input = input + .ok_or_else(|| Error::new(ErrorKind::InvalidInput, "You must provide a path to a post"))?; let post_location = PathBuf::from(input); if !post_location.exists() { return Err(Error::new(ErrorKind::NotFound, "The path provided does not exist"));