Move Options into its own module

This commit is contained in:
Elias Schriefer 2021-07-09 10:02:59 +02:00
parent fa9b77c335
commit 9b4262b996
2 changed files with 24 additions and 19 deletions

21
src/cli.rs Normal file
View File

@ -0,0 +1,21 @@
use structopt::StructOpt;
use std::path::PathBuf;
#[derive(Debug, StructOpt)]
pub struct Options {
/// Path to config
#[structopt(short, long, value_name = "path", default_value = "/etc/noise-server/config.toml")]
pub config: PathBuf,
/// Don't use config
#[structopt(short = "C", long)]
pub no_config: bool,
/// Path to database
#[structopt(short, long, value_name = "path", default_value = crate::DEFAULT_DATABASE_PATH)]
pub database_path: PathBuf,
/// Prints default config
#[structopt(long)]
pub generate_config: bool,
}

View File

@ -21,28 +21,12 @@ use tokio::{
fs::File,
io::AsyncReadExt,
};
use crate::cli::Options;
mod cli;
const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite";
#[derive(Debug, StructOpt)]
struct Options {
/// Path to config
#[structopt(short, long, value_name = "path", default_value = "/etc/noise-server/config.toml")]
config: PathBuf,
/// Don't use config
#[structopt(short = "C", long)]
no_config: bool,
/// Path to database
#[structopt(short, long, value_name = "path", default_value = DEFAULT_DATABASE_PATH)]
database_path: PathBuf,
/// Prints default config
#[structopt(long)]
generate_config: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")]
struct Config {