X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/606f82c76540a9d80366fdb943c06abe525f662e..f7f4335199beaad56d9c962ac84e92a3f78907a6:/src/command/update.rs 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"));