]> git.r.bdr.sh - rbdr/blog/blame - src/command/sync_down.rs
Allow adding / updating
[rbdr/blog] / src / command / sync_down.rs
CommitLineData
a9c6be41
RBR
1use std::fs::create_dir_all;
2use std::io::{Result, Error};
3use crate::configuration::Configuration;
d620665f
RBR
4
5pub struct SyncDown;
6
7impl SyncDown {
8 pub fn new() -> Self {
9 SyncDown
10 }
11}
12
13impl super::Command for SyncDown {
14 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
15 vec![]
16 }
17
a9c6be41
RBR
18 fn execute(&self, _: Option<&String>, configuration: &Configuration, command: &String) -> Result<()> {
19 match create_dir_all(&configuration.data_directory) {
20 Ok(_) => {
21 // We only care to show these warnings if this is the primary command.
22 if command == self.command() {
23 println!("WARNING: Sync Down Not yet implemented");
24 }
25 return Ok(())
26 },
27 Err(e) => Err(Error::new(e.kind(), format!("Could not create data directory")))
28 }
d620665f
RBR
29 }
30
31 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
32 vec![]
33 }
34
35 fn command(&self) -> &'static str {
36 "sync-down"
37 }
38
39 fn help(&self) -> &'static str {
2f579cf4 40 "\t\t\t\tPulls from the git remote if configured"
d620665f
RBR
41 }
42}
43