]> git.r.bdr.sh - rbdr/blog/blame - src/command/publish_archive.rs
Generate and archive blog, allow publishing
[rbdr/blog] / src / command / publish_archive.rs
CommitLineData
d620665f 1use std::io::Result;
a9c6be41 2use crate::configuration::Configuration;
6352ebb0
RBR
3use std::process::{Command, Stdio};
4
5const COMMAND: &str = "rsync";
d620665f
RBR
6
7pub struct PublishArchive;
8
9impl PublishArchive {
10 pub fn new() -> Self {
11 PublishArchive
12 }
13}
14
15impl super::Command for PublishArchive {
16 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
17 vec![]
18 }
19
6352ebb0
RBR
20 fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
21
22 let input = input.expect("You must provide a location to publish the archive");
23
24 Command::new(COMMAND)
25 .arg("--version")
26 .stdout(Stdio::null())
27 .stderr(Stdio::null())
28 .status()
29 .expect("Publishing requires rsync");
30
31
32 Command::new(COMMAND)
33 .arg("-r")
34 .arg(format!("{}/", &configuration.archive_output_directory.display()))
35 .arg(input.as_str())
36 .stdout(Stdio::null())
37 .stderr(Stdio::null())
38 .status()
39 .expect("Publishing requires rsync");
d620665f
RBR
40 return Ok(())
41 }
42
43 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
44 vec![]
45 }
46
47 fn command(&self) -> &'static str {
48 "publish-archive"
49 }
50
51 fn help(&self) -> &'static str {
2f579cf4 52 "<destination>\tPublishes the archive to a remote host"
d620665f
RBR
53 }
54}