]>
Commit | Line | Data |
---|---|---|
1 | use std::io::Result; | |
2 | use crate::configuration::Configuration; | |
3 | use crate::remote::sync_up; | |
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(&self, _: Option<&String>, configuration: &Configuration, command: &String) -> Result<()> { | |
19 | match sync_up(&configuration.data_directory, &configuration.remote_config) { | |
20 | Ok(_) => {} | |
21 | Err(e) => { | |
22 | if command == self.command() { | |
23 | return Err(e) | |
24 | } | |
25 | } | |
26 | } | |
27 | return Ok(()) | |
28 | } | |
29 | ||
30 | fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> { | |
31 | vec![] | |
32 | } | |
33 | ||
34 | fn command(&self) -> &'static str { | |
35 | "sync-up" | |
36 | } | |
37 | ||
38 | fn help(&self) -> &'static str { | |
39 | "\t\t\t\tPushes to the git remote if configured" | |
40 | } | |
41 | } |