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