main: use dotenv to load .env

This commit is contained in:
2026-06-08 18:41:47 +02:00
parent 30a4424252
commit b2bfeeec4d
3 changed files with 11 additions and 1 deletions
Generated
+7
View File
@@ -841,6 +841,12 @@ dependencies = [
"litrs",
]
[[package]]
name = "dotenv"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "dtoa"
version = "1.0.11"
@@ -987,6 +993,7 @@ dependencies = [
"chrono",
"color-eyre",
"crossterm",
"dotenv",
"futures",
"futures-timer",
"hound",
+1
View File
@@ -10,6 +10,7 @@ better-panic = "0.3.0"
chrono = { version = "0.4.44", features = ["serde"] }
color-eyre = "0.6.5"
crossterm = { version = "0.29.0", features = ["event-stream"] }
dotenv = "0.15.0"
futures = "0.3.32"
futures-timer = "3.0.4"
hound = "3.5.1"
+3 -1
View File
@@ -587,7 +587,9 @@ async fn main() {
println!("Panic: {}", msg);
}));
if option_env!("OPENAI_API_KEY").is_none() {
dotenv::dotenv().ok();
if std::env::var("OPENAI_API_KEY").is_err() {
eprintln!("Error: OPENAI_API_KEY environment variable not set. The application will not function without it.");
return;
}