- fn execute(&self, input: Option<&String>) -> Result<()> {
- println!("Update: {:?}!", input);
+ fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
+ let input = input.expect("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"));
+ }
+
+ create_dir_all(&configuration.posts_directory)?;
+
+ let metadata_file_path = configuration.posts_directory
+ .join("0")
+ .join(METADATA_FILENAME);
+ let metadata = Metadata::read_or_create(&metadata_file_path);
+
+ self.copy_post(&post_location);
+ self.write_metadata(metadata, &metadata_file_path);
+ self.archive(&post_location);