| 5 | #[derive(Parser, Debug, PartialEq)] |
| 6 | #[command(author, version, about, long_about = None)] |
| 7 | pub struct Config { |
| 8 | /// Which errors we want to log (info, warn or error) |
| 9 | #[arg(short, long, default_value = "warn")] |
| 10 | pub log_level: String, |
| 11 | /// Which PORT the server is listening to |
| 12 | #[arg(short, long, default_value = "8080")] |
| 13 | pub port: u16, |
| 14 | /// Database user |
| 15 | #[arg(long, default_value = "username")] |
| 16 | pub db_user: String, |
| 17 | /// Database user |
| 18 | #[arg(long, default_value = "password")] |
| 19 | pub db_password: String, |
| 20 | /// URL for the postgres database |
| 21 | #[arg(long, default_value = "localhost")] |
| 22 | pub db_host: String, |
| 23 | /// PORT number for the database connection |
| 24 | #[arg(long, default_value = "5432")] |
| 25 | pub db_port: u16, |
| 26 | /// Database name |
| 27 | #[arg(long, default_value = "rustwebdev")] |
| 28 | pub db_name: String, |
| 29 | } |
| 30 | |
| 31 | impl Config { |
| 32 | pub fn new() -> Result<Config, handle_errors::Error> { |
nothing calls this directly
no outgoing calls
no test coverage detected