Move Options into its own module
This commit is contained in:
		
							
								
								
									
										21
									
								
								src/cli.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/cli.rs
									
									
									
									
									
										Normal 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, | ||||||
|  | } | ||||||
							
								
								
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -21,28 +21,12 @@ use tokio::{ | |||||||
|     fs::File, |     fs::File, | ||||||
|     io::AsyncReadExt, |     io::AsyncReadExt, | ||||||
| }; | }; | ||||||
|  | use crate::cli::Options; | ||||||
|  |  | ||||||
|  | mod cli; | ||||||
|  |  | ||||||
| const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; | 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)] | #[derive(Debug, Serialize, Deserialize)] | ||||||
| #[serde(default, rename_all = "kebab-case")] | #[serde(default, rename_all = "kebab-case")] | ||||||
| struct Config { | struct Config { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user