Use sqlite database from command line arg

This commit is contained in:
Greg Shuflin 2025-02-02 16:55:34 -08:00
parent 2fb3090d9b
commit 5c295d09df
2 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,2 @@
[default.databases.rss_data] [default]
url = "sqlite:data.sqlite"
secret_key = "MHSePvm1msyOkYuJ7u+MtyJYCzgdHCS7QNvrk9ts+rI=" secret_key = "MHSePvm1msyOkYuJ7u+MtyJYCzgdHCS7QNvrk9ts+rI="

View File

@ -20,7 +20,7 @@ use user::AuthenticatedUser;
struct Args { struct Args {
/// Path to the SQLite database file /// Path to the SQLite database file
#[arg(short, long)] #[arg(short, long)]
database: Option<String>, database: String,
} }
#[derive(Database)] #[derive(Database)]
@ -44,9 +44,14 @@ fn login() -> Template {
#[launch] #[launch]
fn rocket() -> _ { fn rocket() -> _ {
let _args = Args::parse(); let args = Args::parse();
rocket::build() let figment = rocket::Config::figment().merge((
"databases.rss_data.url",
format!("sqlite:{}", args.database),
));
rocket::custom(figment)
.mount( .mount(
"/", "/",
routes![ routes![