]>
Commit | Line | Data |
---|---|---|
1 | use crate::configuration::Configuration; | |
2 | use crate::remote::add; | |
3 | use std::io::{Error, ErrorKind::Other, Result}; | |
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 | ||
18 | fn execute( | |
19 | &self, | |
20 | input: Option<&String>, | |
21 | configuration: &Configuration, | |
22 | _: &str, | |
23 | ) -> Result<()> { | |
24 | let input = input | |
25 | .ok_or_else(|| Error::new(Other, "You must provide a location for the remote."))?; | |
26 | add( | |
27 | &configuration.config_directory, | |
28 | &configuration.remote_config, | |
29 | input, | |
30 | ) | |
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 | } |