From a4da0598f614e95a6ad334895633bfd962e16efe Mon Sep 17 00:00:00 2001 From: Jon Seager Date: Tue, 3 Feb 2026 18:00:09 +0000 Subject: [PATCH] feat: load environment variables from .env file via dotenvy Add dotenvy::dotenv() call before CLI argument parsing so that environment variables (e.g. API keys) can be set in a .env file instead of the shell environment. Add .env to .gitignore. --- .gitignore | 3 ++- src/main.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7c728ef..99e8cdc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ result* brewlog.db TODO.md SPEC.md -backup.json \ No newline at end of file +backup.json +.env \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 503b2a0..3cf5b33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,9 @@ use tracing_subscriber::{EnvFilter, Registry, layer::SubscriberExt}; #[tokio::main] async fn main() -> Result<()> { + // Load .env file if present (before clap parses env vars) + let _ = dotenvy::dotenv(); + let subscriber = get_subscriber("brewlog".into(), "info".into(), std::io::stdout); init_subscriber(subscriber); @@ -81,6 +84,8 @@ async fn run_server(command: ServeCommand) -> Result<()> { database_url: command.database_url, admin_password: command.admin_password, admin_username: command.admin_username, + openrouter_api_key: command.openrouter_api_key, + openrouter_model: command.openrouter_model, }; serve(config).await