Basic cli parse of postgres params

This commit is contained in:
shockrah 2024-12-15 17:02:30 -08:00
parent d55714a6f0
commit a679f49b18

View File

@ -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<String>,
}
#[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,