2021-06-08 15:18:56 +02:00
|
|
|
use structopt::StructOpt;
|
|
|
|
use std::path::PathBuf;
|
2021-06-08 15:57:04 +02:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
|
2021-06-08 15:18:56 +02:00
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
struct Options {
|
|
|
|
#[structopt(short, long, default_value = "/etc/noise-server/config.toml")]
|
|
|
|
config: PathBuf,
|
|
|
|
|
2021-06-08 15:57:04 +02:00
|
|
|
#[structopt(short, long, default_value = DEFAULT_DATABASE_PATH)]
|
|
|
|
database_path: PathBuf,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
|
|
|
struct Config {
|
2021-06-08 15:18:56 +02:00
|
|
|
database_path: PathBuf,
|
2021-06-08 15:57:04 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Config {
|
|
|
|
fn default() -> Self {
|
|
|
|
Config {
|
|
|
|
database_path: DEFAULT_DATABASE_PATH.into(),
|
|
|
|
}
|
|
|
|
}
|
2021-06-08 15:18:56 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 19:42:24 +02:00
|
|
|
fn main() {
|
2021-06-08 15:18:56 +02:00
|
|
|
let options = Options::from_args();
|
2021-06-08 15:57:04 +02:00
|
|
|
#[cfg(debug_assertions)]
|
|
|
|
println!("{:?}", options);
|
2021-04-06 19:42:24 +02:00
|
|
|
}
|