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
#![feature(proc_macro_hygiene)]

pub mod args;

pub mod log;

pub mod server;

use dbui_core::config::cfg::AppConfig;

#[cfg(debug_assertions)]
fn is_debug() -> bool { true }

#[cfg(not(debug_assertions))]
fn is_debug() -> bool { false }

pub fn go() -> std::io::Result<()> {
  let matches = args::get_matches();
  let cfg_dir = match matches.value_of("config") {
    None => String::from("./tests/testbed"),
    Some(o) => String::from(o)
  };
  let address = match matches.value_of("address") {
    None => String::from("127.0.0.1"),
    Some(o) => String::from(o)
  };
  let verbose = matches.is_present("verbose") || is_debug();
  let port: i32 = match matches.value_of("port") {
    Some(p) => p.parse().unwrap(),
    None => 4200
  };
  let _e = "String".parse::<dbui_core::models::field_type::FieldType>();

  let log = crate::log::root_logger(verbose);
  let cfg = AppConfig::new(cfg_dir, address, port, verbose, log);
  server::start_server(cfg)
}