]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/publish_archive.rs
Allow sync up and down
[rbdr/blog] / src / command / publish_archive.rs
index 6b98b1a4a867645c21650735a2136e0955b0dcbc..075421f0ac1b25c1f2738724f656832af6692363 100644 (file)
@@ -1,4 +1,8 @@
 use std::io::Result;
 use std::io::Result;
+use crate::configuration::Configuration;
+use std::process::{Command, Stdio};
+
+const COMMAND: &str = "rsync";
 
 pub struct PublishArchive;
 
 
 pub struct PublishArchive;
 
@@ -13,8 +17,26 @@ impl super::Command for PublishArchive {
         vec![]
     }
 
         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(())
     }
 
         return Ok(())
     }