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.
This commit is contained in:
Jon Seager 2026-02-03 18:00:09 +00:00
parent acaadbbcf6
commit a4da0598f6
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ brewlog.db
TODO.md
SPEC.md
backup.json
.env

View file

@ -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