]> git.r.bdr.sh - rbdr/blog/blame - src/command/add_remote.rs
Deal with all lints
[rbdr/blog] / src / command / add_remote.rs
CommitLineData
a9c6be41 1use crate::configuration::Configuration;
172f4c88 2use crate::remote::add;
d7fef30a 3use std::io::{Error, ErrorKind::Other, Result};
d620665f
RBR
4
5pub struct AddRemote;
6
7impl AddRemote {
8 pub fn new() -> Self {
9 AddRemote
10 }
11}
12
13impl super::Command for AddRemote {
14 fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
15 vec![]
16 }
17
d7fef30a
RBR
18 fn execute(
19 &self,
20 input: Option<&String>,
21 configuration: &Configuration,
22 _: &str,
23 ) -> Result<()> {
50f53dc4
RBR
24 let input = input
25 .ok_or_else(|| Error::new(Other, "You must provide a location for the remote."))?;
d7fef30a
RBR
26 add(
27 &configuration.config_directory,
28 &configuration.remote_config,
29 input,
30 )
d620665f
RBR
31 }
32
33 fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
34 vec![]
35 }
36
37 fn command(&self) -> &'static str {
38 "add-remote"
39 }
40
41 fn help(&self) -> &'static str {
42 "<git_url>\t\tAdds or updates a git remote to sync with"
43 }
44}