aboutsummaryrefslogtreecommitdiff
path: root/src/cli/mod.rs
blob: 851812f5136b9b07a07c33a31687ea751a5d51fd (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
use structopt::StructOpt;

use crate::{Settings, UrlMap, db::backend::Connectable};

mod make_migrations;
mod migrate;
mod run_server;

#[derive(StructOpt)]
enum Command {
    MakeMigrations(make_migrations::MakeMigrations),
    Migrate(migrate::Migrate),
    RunServer(run_server::RunServer),
}

impl Command {
    fn execute(self, urls: UrlMap, settings: Settings<impl Connectable>) {
        match self {
            Command::MakeMigrations(command) => command.execute(urls, settings),
            Command::Migrate(command) => command.execute(urls, settings),
            Command::RunServer(command) => command.execute(urls, settings),
        }
    }
}

pub fn main(urls: UrlMap, settings: Settings<impl Connectable>) {
    let command = Command::from_args();
    command.execute(urls, settings);
}