Add option for usage without config
This commit is contained in:
		| @@ -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<Config> { | ||||
|     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)?; | ||||
| @@ -104,3 +111,4 @@ fn get_config(options: &Options) -> std::io::Result<Config> { | ||||
|         ) | ||||
|     ) | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user