aboutsummaryrefslogtreecommitdiff
path: root/src/command/status/mod.rs
blob: b92ef5f87f52adef88032637f32c2c7f89b2d36a (plain)
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
mod blog_status;
mod configuration_status;

use crate::configuration::Configuration;
use std::io::Result;

pub struct Status;

impl Status {
    pub fn new() -> Self {
        Status
    }
}

impl super::Command for Status {
    fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
        vec![]
    }

    fn execute(&self, _: Option<&String>, configuration: &Configuration, _: &str) -> Result<()> {
        let status_providers = available_status_providers();
        for status_provider in status_providers {
            println!("{}\n----\n", status_provider(configuration));
        }
        Ok(())
    }

    fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
        vec![]
    }

    fn command(&self) -> &'static str {
        "status"
    }

    fn help(&self) -> &'static str {
        "\t\t\t\tPrints the status of your blog"
    }
}

fn available_status_providers() -> Vec<fn(&Configuration) -> String> {
    vec![configuration_status::status, blog_status::status]
}