diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..c853a90 --- /dev/null +++ b/src/cli.rs @@ -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, +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 60fd468..ace0340 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {