diff --git a/api/src/main.rs b/api/src/main.rs index 2285c66..9f72567 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -1,9 +1,40 @@ #[macro_use] extern crate rocket; +use std::env; + +use clap::Parser; mod invites; mod channels; +struct Config { + postgres_user: String, + postgrse_pass: String +} + +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Args { + /// Set the postgres username to use for the API ( default is bubble_admin ) + #[arg(short, long, default_value = "bubble_admin")] + psql_user: String, + /// Set the postgres password to use for the API ( Uses POSTGRES_PASSWORD + /// environment variable by default ) + psql_pass: Option, + +} + + #[rocket::main] async fn main() -> Result<(), rocket::Error> { + let args = Args::parse(); + let psql_pass = match args.psql_pass { + Some(pass) => pass, + None => match env::var("PSQL_PASS") { + Ok(pass) => pass, + Err(_) => panic!("PSQL_PASS is not set!") + } + }; + + let _ = rocket::build() .mount("/channels", routes![ channels::list,