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
mod csv_data;
mod db;
mod token;

use csv_data::CsvDataCommand;
use db::DbCommand;
use token::ApiTokenCommand;

use crate::common::startup::get_cli_exe;
use std::{path::PathBuf, process::Command};

pub struct VitCliCommand {
    exe: PathBuf,
}

impl Default for VitCliCommand {
    fn default() -> Self {
        Self::new(get_cli_exe())
    }
}

impl VitCliCommand {
    pub fn new(exe: PathBuf) -> Self {
        Self { exe }
    }

    pub fn api_token(self) -> ApiTokenCommand {
        let mut command = Command::new(self.exe);
        command.arg("api-token");
        ApiTokenCommand::new(command)
    }

    pub fn db(self) -> DbCommand {
        let mut command = Command::new(self.exe);
        command.arg("db");
        DbCommand::new(command)
    }

    pub fn csv_data(self) -> CsvDataCommand {
        let mut command = Command::new(self.exe);
        command.arg("csv-data");
        CsvDataCommand::new(command)
    }
}