1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
pub mod add;
pub mod generate;
pub mod update;
pub mod publish;
pub mod publish_archive;
pub mod add_remote;
pub mod remove_remote;
pub mod sync_up;
pub mod sync_down;
pub mod status;
pub mod version;
pub mod help;
use std::io::Result;
use add::Add;
use generate::Generate;
use update::Update;
use publish::Publish;
use publish_archive::PublishArchive;
use add_remote::AddRemote;
use remove_remote::RemoveRemote;
use sync_up::SyncUp;
use sync_down::SyncDown;
use version::Version;
use status::Status;
use help::Help;
use crate::configuration::Configuration;
pub trait Command {
fn before_dependencies(&self) -> Vec<Box<dyn Command>>;
fn execute(&self, input: Option<&String>, configuration: &Configuration, command: &String) -> Result<()>;
fn after_dependencies(&self) -> Vec<Box<dyn Command>>;
fn command(&self) -> &'static str;
fn help(&self) -> &'static str;
}
pub fn available_commands() -> Vec<Box<dyn Command>> {
vec![
Box::new(Add::new()),
Box::new(Generate::new()),
Box::new(Update::new()),
Box::new(Publish::new()),
Box::new(PublishArchive::new()),
Box::new(AddRemote::new()),
Box::new(RemoveRemote::new()),
Box::new(SyncUp::new()),
Box::new(SyncDown::new()),
Box::new(Status::new()),
Box::new(Version::new()),
Box::new(Help::new())
]
}
|