X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/d620665f6b2e1ae5db4c98a09e35bd63133ae87f..6352ebb0eb4cb83240c6d4998e0ef1375b041191:/src/command/publish_archive.rs diff --git a/src/command/publish_archive.rs b/src/command/publish_archive.rs index 4275c38..075421f 100644 --- a/src/command/publish_archive.rs +++ b/src/command/publish_archive.rs @@ -1,4 +1,8 @@ use std::io::Result; +use crate::configuration::Configuration; +use std::process::{Command, Stdio}; + +const COMMAND: &str = "rsync"; pub struct PublishArchive; @@ -13,8 +17,26 @@ impl super::Command for PublishArchive { vec![] } - fn execute(&self, input: Option<&String>) -> Result<()> { - println!("Publish Archive: {:?}!", input); + fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> { + + let input = input.expect("You must provide a location to publish the archive"); + + Command::new(COMMAND) + .arg("--version") + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .expect("Publishing requires rsync"); + + + Command::new(COMMAND) + .arg("-r") + .arg(format!("{}/", &configuration.archive_output_directory.display())) + .arg(input.as_str()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .expect("Publishing requires rsync"); return Ok(()) } @@ -27,6 +49,6 @@ impl super::Command for PublishArchive { } fn help(&self) -> &'static str { - "\tPublishes the archive to a remote host." + "\tPublishes the archive to a remote host" } }