]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/sync_down.rs
Add part of the implementation for add
[rbdr/blog] / src / command / sync_down.rs
index a0c713be1d3541be18dacdfd3b5e9e7220e80f55..dc4114e8d31f0836a047b5fbc76c1bb6127e422c 100644 (file)
@@ -1,4 +1,6 @@
-use std::io::Result;
+use std::fs::create_dir_all;
+use std::io::{Result, Error};
+use crate::configuration::Configuration;
 
 pub struct SyncDown;
 
@@ -13,9 +15,17 @@ impl super::Command for SyncDown {
         vec![]
     }
 
-    fn execute(&self, input: Option<&String>) -> Result<()> {
-        println!("Sync Down: {:?}!", input);
-        return Ok(())
+    fn execute(&self, _: Option<&String>, configuration: &Configuration, command: &String) -> Result<()> {
+        match create_dir_all(&configuration.data_directory) {
+            Ok(_) => {
+                // We only care to show these warnings if this is the primary command.
+                if command == self.command() {
+                    println!("WARNING: Sync Down Not yet implemented");
+                }
+                return Ok(())
+            },
+            Err(e) => Err(Error::new(e.kind(), format!("Could not create data directory")))
+        }
     }
 
     fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
@@ -27,7 +37,7 @@ impl super::Command for SyncDown {
     }
 
     fn help(&self) -> &'static str {
-        "\t\t\tPulls from the git remote if configured"
+        "\t\t\t\tPulls from the git remote if configured"
     }
 }