1 use std::fs::{create_dir_all, rename};
9 use crate::configuration::Configuration;
14 pub fn new() -> Self {
19 impl super::Command for Add {
20 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
21 vec![Box::new(SyncDown::new())]
24 fn execute(&self, _: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
25 create_dir_all(&configuration.posts_directory)?;
26 for i in (0..configuration.max_posts).rev() {
27 let source = configuration.posts_directory.join(i.to_string());
28 let target = configuration.posts_directory.join((i + 1).to_string());
31 rename(&source, &target)?;
37 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
39 Box::new(Update::new()),
40 Box::new(Generate::new()),
41 Box::new(SyncUp::new())
45 fn command(&self) -> &'static str {
49 fn help(&self) -> &'static str {
50 "<path_to_post>\t\t\tCreates new blog post"