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
use crate::Result;
use std::env::current_dir;
use std::fs::create_dir;
use std::process::{exit};
use yansi::Paint;

pub trait SetupCommand {
    fn run(&self) -> Result<()>;
}

pub struct SetupCommandImpl;

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

impl SetupCommand for SetupCommandImpl {
    fn run(&self) -> Result<()> {
        let setup_path = current_dir()?.join(".mdmg");
        if setup_path.exists() {
            println!("Already setuped");
            exit(1);
        }
        create_dir(".mdmg")?;
        println!("{}", Paint::green("Setup complete mdmg"));
        Ok(())
    }
}