feat: load config from proper location
also adds a way to change load location using cmdline arguments
This commit is contained in:
parent
7eea0cd4fe
commit
026d48c6e7
3 changed files with 15 additions and 6 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,5 +1,6 @@
|
|||
use actix_web::{App, HttpServer, web};
|
||||
use argon2::Argon2;
|
||||
use clap::Parser;
|
||||
use sqlx::{PgPool, Pool, Postgres};
|
||||
use std::time::SystemTime;
|
||||
mod config;
|
||||
|
@ -8,6 +9,14 @@ mod api;
|
|||
|
||||
type Error = Box<dyn std::error::Error>;
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
#[arg(short, long, default_value_t = String::from("/etc/gorb/config.toml"))]
|
||||
config: String,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Data {
|
||||
pub pool: Pool<Postgres>,
|
||||
|
@ -18,7 +27,9 @@ struct Data {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Error> {
|
||||
let config = ConfigBuilder::load().await?.build();
|
||||
let args = Args::parse();
|
||||
|
||||
let config = ConfigBuilder::load(args.config).await?.build();
|
||||
|
||||
let web = config.web.clone();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue