use std::fs::{create_dir_all, write}; use std::io::Result; use crate::configuration::Configuration; pub struct AddRemote; impl AddRemote { pub fn new() -> Self { AddRemote } } impl super::Command for AddRemote { fn before_dependencies(&self) -> Vec> { vec![] } 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(()) } fn after_dependencies(&self) -> Vec> { vec![] } fn command(&self) -> &'static str { "add-remote" } fn help(&self) -> &'static str { "\t\tAdds or updates a git remote to sync with" } }