`database-path` in config was correct, but was being overwritten by `--database-path` option. In a test case the option was not given, but clap/structopt marked it as `present`. The occurrences were `0` though.
44 lines
1.0 KiB
Rust
44 lines
1.0 KiB
Rust
use structopt::StructOpt;
|
|
use std::{
|
|
boxed::Box,
|
|
error::Error,
|
|
};
|
|
use tokio::sync::RwLock;
|
|
use crate::{
|
|
cli::Options,
|
|
config::Config,
|
|
};
|
|
|
|
mod cli;
|
|
mod config;
|
|
#[cfg(feature = "sqlite")]
|
|
mod sqlite;
|
|
|
|
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
|
let clap_matches = Options::clap().get_matches();
|
|
let options = Options::from_clap(&clap_matches);
|
|
|
|
if options.generate_config {
|
|
println!("{}", toml::to_string_pretty(&Config::default())?);
|
|
return Ok(());
|
|
}
|
|
|
|
let mut config = Config::get(&options).await?;
|
|
|
|
if clap_matches.occurrences_of("database-path") > 0 {
|
|
config.database_path = options.database_path.clone();
|
|
}
|
|
|
|
dbg!(&config);
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
let mut sqlite_connection = RwLock::new(sqlite::connect(&config.database_path).await?);
|
|
|
|
#[cfg(feature = "sqlite")]
|
|
sqlite::load_template(sqlite_connection.get_mut()).await?;
|
|
|
|
Ok(())
|
|
} |