]> git.r.bdr.sh - rbdr/blog/blob - src/command/sync_down.rs
dc4114e8d31f0836a047b5fbc76c1bb6127e422c
[rbdr/blog] / src / command / sync_down.rs
1 use std::fs::create_dir_all;
2 use std::io::{Result, Error};
3 use crate::configuration::Configuration;
4
5 pub struct SyncDown;
6
7 impl SyncDown {
8 pub fn new() -> Self {
9 SyncDown
10 }
11 }
12
13 impl super::Command for SyncDown {
14 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
15 vec![]
16 }
17
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 }
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 {
40 "\t\t\t\tPulls from the git remote if configured"
41 }
42 }
43