use crate::configuration::Configuration;
use crate::constants::METADATA_FILENAME;
use crate::metadata::Metadata;
+use serde_json;
pub struct 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(())
}
}
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"));