From fc2ae6cf0a38b6669c682129ece091c5a427a96c Mon Sep 17 00:00:00 2001 From: EliasSchriefer Date: Thu, 8 Jul 2021 12:53:02 +0200 Subject: [PATCH] Add option for usage without config --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 7c49673..8269385 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,10 @@ struct Options { #[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, @@ -93,6 +97,9 @@ async fn load_sqlite_template(sqlite_handle: &mut SqliteConnection) -> sqlx::Res } fn get_config(options: &Options) -> std::io::Result { + if options.no_config { + Ok(Config::default()) + } else { let mut config_file = File::open(&options.config)?; let mut config_string = String::new(); config_file.read_to_string(&mut config_string)?; @@ -103,4 +110,5 @@ fn get_config(options: &Options) -> std::io::Result { err ) ) +} } \ No newline at end of file