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:
parent
acaadbbcf6
commit
a4da0598f6
2 changed files with 7 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ brewlog.db
|
||||||
TODO.md
|
TODO.md
|
||||||
SPEC.md
|
SPEC.md
|
||||||
backup.json
|
backup.json
|
||||||
|
.env
|
||||||
|
|
@ -16,6 +16,9 @@ use tracing_subscriber::{EnvFilter, Registry, layer::SubscriberExt};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
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);
|
let subscriber = get_subscriber("brewlog".into(), "info".into(), std::io::stdout);
|
||||||
init_subscriber(subscriber);
|
init_subscriber(subscriber);
|
||||||
|
|
||||||
|
|
@ -81,6 +84,8 @@ async fn run_server(command: ServeCommand) -> Result<()> {
|
||||||
database_url: command.database_url,
|
database_url: command.database_url,
|
||||||
admin_password: command.admin_password,
|
admin_password: command.admin_password,
|
||||||
admin_username: command.admin_username,
|
admin_username: command.admin_username,
|
||||||
|
openrouter_api_key: command.openrouter_api_key,
|
||||||
|
openrouter_model: command.openrouter_model,
|
||||||
};
|
};
|
||||||
|
|
||||||
serve(config).await
|
serve(config).await
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue