]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/publish.rs
Generate and archive blog, allow publishing
[rbdr/blog] / src / command / publish.rs
index 881c9876e8d6c9b590340a7bef1dc100aa179bbe..207b45ddeda0cb56d913ffa863a0ee30ad2a12a7 100644 (file)
@@ -1,5 +1,8 @@
 use std::io::Result;
 use crate::configuration::Configuration;
+use std::process::{Command, Stdio};
+
+const COMMAND: &str = "rsync";
 
 pub struct Publish;
 
@@ -14,8 +17,26 @@ impl super::Command for Publish {
         vec![]
     }
 
-    fn execute(&self, input: Option<&String>, _: &Configuration, _: &String) -> Result<()> {
-        println!("Publish: {:?}!", input);
+    fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
+
+        let input = input.expect("You must provide a location to publish the blog");
+
+        Command::new(COMMAND)
+            .arg("--version")
+            .stdout(Stdio::null())
+            .stderr(Stdio::null())
+            .status()
+            .expect("Publishing requires rsync");
+
+
+        Command::new(COMMAND)
+            .arg("-r")
+            .arg(format!("{}/", &configuration.blog_output_directory.display()))
+            .arg(input.as_str())
+            .stdout(Stdio::null())
+            .stderr(Stdio::null())
+            .status()
+            .expect("Publishing requires rsync");
         return Ok(())
     }