X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/36a4680d18de012e2e5c732f9db161dafa884344..edcd0e51b3e0a6d52a560f293b7e6a08999cfd0c:/src/command/add_remote.rs?ds=sidebyside diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs index ad7be83..e9157f3 100644 --- a/src/command/add_remote.rs +++ b/src/command/add_remote.rs @@ -1,6 +1,6 @@ -use std::fs::{create_dir_all, write}; -use std::io::Result; +use std::io::{Error, ErrorKind::Other, Result}; use crate::configuration::Configuration; +use crate::remote::add; pub struct AddRemote; @@ -16,10 +16,9 @@ impl super::Command for AddRemote { } fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> { - create_dir_all(&configuration.config_directory)?; - let input = input.expect("You must provide a location for the remote."); - write(&configuration.remote_config, input)?; - return Ok(()) + 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> {