]>
Commit | Line | Data |
---|---|---|
1 | use crate::configuration::Configuration; | |
2 | use crate::remote::sync_up; | |
3 | use std::io::Result; | |
4 | ||
5 | pub struct SyncUp; | |
6 | ||
7 | impl SyncUp { | |
8 | pub fn new() -> Self { | |
9 | SyncUp | |
10 | } | |
11 | } | |
12 | ||
13 | impl super::Command for SyncUp { | |
14 | fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> { | |
15 | vec![] | |
16 | } | |
17 | ||
18 | fn execute( | |
19 | &self, | |
20 | _: Option<&String>, | |
21 | configuration: &Configuration, | |
22 | command: &str, | |
23 | ) -> Result<()> { | |
24 | match sync_up(&configuration.data_directory, &configuration.remote_config) { | |
25 | Ok(()) => {} | |
26 | Err(e) => { | |
27 | if command == self.command() { | |
28 | return Err(e); | |
29 | } | |
30 | } | |
31 | } | |
32 | Ok(()) | |
33 | } | |
34 | ||
35 | fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> { | |
36 | vec![] | |
37 | } | |
38 | ||
39 | fn command(&self) -> &'static str { | |
40 | "sync-up" | |
41 | } | |
42 | ||
43 | fn help(&self) -> &'static str { | |
44 | "\t\t\t\tPushes to the git remote if configured" | |
45 | } | |
46 | } |