#![feature(bool_to_option)] mod cli; mod config; mod db; mod queries; mod server; mod static_files; mod templates; mod utils; use structopt::StructOpt; #[async_std::main] async fn main() { let opt = cli::MainOpt::from_args(); match opt.cmd { cli::MainSubcommand::Init => { init_all(opt); } cli::MainSubcommand::Start => { let (config, dbs, templates) = init_all(opt.clone()); server::start_server(config, dbs, templates, opt).await } } } fn init_all<'reg>(opt: cli::MainOpt) -> (config::Config, db::Dbs, templates::Templates<'reg>) { std::fs::create_dir_all(&opt.dir.0).expect("Cannot create dir"); static_files::init_static_files(&opt.dir.0); ( config::read_config(&opt.dir.0), db::load_dbs(&opt.dir.0), templates::load_templates(&opt.dir.0), ) }