diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-08 23:38:23 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-08 23:38:23 +0100 |
| commit | 6352ebb0eb4cb83240c6d4998e0ef1375b041191 (patch) | |
| tree | 3ade08c77c8ab403d3196f80fad5ed3034c3035b /src/command/publish.rs | |
| parent | 60307a9a3a39dccf652c9d9b4348e44db1e67627 (diff) | |
Generate and archive blog, allow publishing
Diffstat (limited to 'src/command/publish.rs')
| -rw-r--r-- | src/command/publish.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/command/publish.rs b/src/command/publish.rs index 881c987..207b45d 100644 --- a/src/command/publish.rs +++ b/src/command/publish.rs @@ -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(()) } |