Basic cli parse of postgres params
This commit is contained in:
parent
d55714a6f0
commit
a679f49b18
@ -1,9 +1,40 @@
|
|||||||
#[macro_use] extern crate rocket;
|
#[macro_use] extern crate rocket;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
mod invites;
|
mod invites;
|
||||||
mod channels;
|
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]
|
#[rocket::main]
|
||||||
async fn main() -> Result<(), rocket::Error> {
|
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()
|
let _ = rocket::build()
|
||||||
.mount("/channels", routes![
|
.mount("/channels", routes![
|
||||||
channels::list,
|
channels::list,
|
||||||
|
Loading…
Reference in New Issue
Block a user