1 use std::io::{Error, ErrorKind::Other, Result};
2 use crate::configuration::Configuration;
3 use std::process::{Command, Stdio};
5 const COMMAND: &str = "rsync";
10 pub fn new() -> Self {
15 impl super::Command for Publish {
16 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
20 fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
23 .ok_or_else(|| Error::new(Other, "You must provide a location to publish the blog"))?;
27 .stdout(Stdio::null())
28 .stderr(Stdio::null())
30 .map_err(|_| Error::new(Other, "Publishing requires rsync"))?;
35 .arg(format!("{}/", &configuration.blog_output_directory.display()))
37 .stdout(Stdio::null())
38 .stderr(Stdio::null())
40 .map_err(|_| Error::new(Other, "Rsync failed to publish."))?;
44 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
48 fn command(&self) -> &'static str {
52 fn help(&self) -> &'static str {
53 "<destination>\t\tPublishes the blog to a remote host"