1 use std::io::{Error, ErrorKind::Other, Result};
2 use crate::configuration::Configuration;
3 use std::process::{Command, Stdio};
5 const COMMAND: &str = "rsync";
7 pub struct PublishArchive;
10 pub fn new() -> Self {
15 impl super::Command for PublishArchive {
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 archive"))?;
27 .stdout(Stdio::null())
28 .stderr(Stdio::null())
30 .map_err(|_| Error::new(Other, "Publishing requires rsync"))?;
35 .arg(format!("{}/", &configuration.archive_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>\tPublishes the archive to a remote host"