aboutsummaryrefslogtreecommitdiff
path: root/src/command/status/mod.rs
blob: e620f78f8c8615fbe69c651a04552de28bec59dc (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
44
45
46
mod configuration_status;
mod blog_status;

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

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, _: &String) -> Result<()> {
        let status_providers = available_status_providers();
        for status_provider in status_providers {
            println!("{}\n----\n", status_provider(configuration));
        }
        return 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,
    ]
}