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

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

mod migrate;
mod run_server;

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

impl Command {
    fn execute(self, urls: UrlMap, settings: Settings<impl Connectable>) {
        match self {
            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);
}