1 use crate::configuration::Configuration;
2 use std::io::{Error, ErrorKind::Other, Result};
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>> {
22 input: Option<&String>,
23 configuration: &Configuration,
27 .ok_or_else(|| Error::new(Other, "You must provide a location to publish the blog"))?;
31 .stdout(Stdio::null())
32 .stderr(Stdio::null())
34 .map_err(|_| Error::new(Other, "Publishing requires rsync"))?;
40 &configuration.blog_output_directory.display()
43 .stdout(Stdio::null())
44 .stderr(Stdio::null())
46 .map_err(|_| Error::new(Other, "Rsync failed to publish."))?;
50 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
54 fn command(&self) -> &'static str {
58 fn help(&self) -> &'static str {
59 "<destination>\t\tPublishes the blog to a remote host"