]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/add_remote.rs
Deal with all lints
[rbdr/blog] / src / command / add_remote.rs
index 3d901038e9fe53eab703595f35353d930acde88c..e5ca591147650c1a463d99eb39cba8b0ce8e0b4a 100644 (file)
@@ -1,4 +1,6 @@
-use std::io::Result;
+use crate::configuration::Configuration;
+use crate::remote::add;
+use std::io::{Error, ErrorKind::Other, Result};
 
 pub struct AddRemote;
 
@@ -13,9 +15,19 @@ impl super::Command for AddRemote {
         vec![]
     }
 
-    fn execute(&self, input: Option<&String>) -> Result<()> {
-        println!("Add Remote: {:?}!", input);
-        return Ok(())
+    fn execute(
+        &self,
+        input: Option<&String>,
+        configuration: &Configuration,
+        _: &str,
+    ) -> 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>> {