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