use std::io::Result; use crate::configuration::Configuration; use std::process::{Command, Stdio}; const COMMAND: &str = "rsync"; pub struct Publish; impl Publish { pub fn new() -> Self { Publish } } impl super::Command for Publish { fn before_dependencies(&self) -> Vec> { vec![] } fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> { let input = input.expect("You must provide a location to publish the blog"); Command::new(COMMAND) .arg("--version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() .expect("Publishing requires rsync"); Command::new(COMMAND) .arg("-r") .arg(format!("{}/", &configuration.blog_output_directory.display())) .arg(input.as_str()) .stdout(Stdio::null()) .stderr(Stdio::null()) .status() .expect("Publishing requires rsync"); return Ok(()) } fn after_dependencies(&self) -> Vec> { vec![] } fn command(&self) -> &'static str { "publish" } fn help(&self) -> &'static str { "\t\tPublishes the blog to a remote host" } }