]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/add_remote.rs
Manually import
[rbdr/blog] / src / command / add_remote.rs
index c98330fbf7d94fdeae7c64abb841b56c1d5f4c13..e9157f3a5b8208fe83a08c5ed47d7784f7673ea7 100644 (file)
@@ -1,5 +1,6 @@
-use std::io::Result;
+use std::io::{Error, ErrorKind::Other, Result};
 use crate::configuration::Configuration;
 use crate::configuration::Configuration;
+use crate::remote::add;
 
 pub struct AddRemote;
 
 
 pub struct AddRemote;
 
@@ -14,9 +15,10 @@ impl super::Command for AddRemote {
         vec![]
     }
 
         vec![]
     }
 
-    fn execute(&self, input: Option<&String>, _: &Configuration, _: &String) -> Result<()> {
-        println!("Add Remote: {:?}!", input);
-        return Ok(())
+    fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
+        let input = input
+            .ok_or_else(|| Error::new(Other, "You must provide a location for the remote."))?;
+        add(&configuration.config_directory, &configuration.remote_config, input)
     }
 
     fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
     }
 
     fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {