+ fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
+ 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"));
+ }
+
+ // Step 1. Write into the ephemeral posts
+
+ create_dir_all(&configuration.posts_directory)?;
+
+ let first_post_path = configuration.posts_directory.join("0");
+ let metadata_file_path = first_post_path.join(METADATA_FILENAME);
+ let metadata = Metadata::read_or_create(&metadata_file_path);
+
+ let _ = remove_dir_all(&first_post_path);
+ create_dir_all(&first_post_path)?;
+
+ self.copy_post(&post_location, &first_post_path)?;
+ self.write_metadata(&metadata, &metadata_file_path)?;
+
+ // Step 2. Write into the archive
+
+ create_dir_all(&configuration.archive_directory)?;
+
+ let post_archive_path = configuration.archive_directory.join(metadata.id);
+ let _ = remove_dir_all(&post_archive_path);
+ create_dir_all(&post_archive_path)?;
+
+ self.archive(&first_post_path, &post_archive_path)?;