aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 00:48:11 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 00:48:11 +0100
commit36a4680d18de012e2e5c732f9db161dafa884344 (patch)
tree333f961f9df11b568442d67fa8d1145851d661f3 /src
parent6352ebb0eb4cb83240c6d4998e0ef1375b041191 (diff)
Add remote management
Diffstat (limited to 'src')
-rw-r--r--src/command/add_remote.rs7
-rw-r--r--src/command/remove_remote.rs7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs
index c98330f..ad7be83 100644
--- a/src/command/add_remote.rs
+++ b/src/command/add_remote.rs
@@ -1,3 +1,4 @@
+use std::fs::{create_dir_all, write};
use std::io::Result;
use crate::configuration::Configuration;
@@ -14,8 +15,10 @@ impl super::Command for AddRemote {
vec![]
}
- fn execute(&self, input: Option<&String>, _: &Configuration, _: &String) -> Result<()> {
- println!("Add Remote: {:?}!", input);
+ 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(())
}
diff --git a/src/command/remove_remote.rs b/src/command/remove_remote.rs
index 8188beb..b2f554c 100644
--- a/src/command/remove_remote.rs
+++ b/src/command/remove_remote.rs
@@ -1,3 +1,4 @@
+use std::fs::remove_file;
use std::io::Result;
use crate::configuration::Configuration;
@@ -14,8 +15,10 @@ impl super::Command for RemoveRemote {
vec![]
}
- fn execute(&self, input: Option<&String>, _: &Configuration, _: &String) -> Result<()> {
- println!("Remove Remote: {:?}!", input);
+ fn execute(&self, _: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
+ if configuration.remote_config.exists() {
+ remove_file(&configuration.remote_config)?;
+ }
return Ok(())
}