main: use dotenv to load .env
This commit is contained in:
Generated
+7
@@ -841,6 +841,12 @@ dependencies = [
|
|||||||
"litrs",
|
"litrs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenv"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtoa"
|
name = "dtoa"
|
||||||
version = "1.0.11"
|
version = "1.0.11"
|
||||||
@@ -987,6 +993,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
|
"dotenv",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
"hound",
|
"hound",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ better-panic = "0.3.0"
|
|||||||
chrono = { version = "0.4.44", features = ["serde"] }
|
chrono = { version = "0.4.44", features = ["serde"] }
|
||||||
color-eyre = "0.6.5"
|
color-eyre = "0.6.5"
|
||||||
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
crossterm = { version = "0.29.0", features = ["event-stream"] }
|
||||||
|
dotenv = "0.15.0"
|
||||||
futures = "0.3.32"
|
futures = "0.3.32"
|
||||||
futures-timer = "3.0.4"
|
futures-timer = "3.0.4"
|
||||||
hound = "3.5.1"
|
hound = "3.5.1"
|
||||||
|
|||||||
+3
-1
@@ -587,7 +587,9 @@ async fn main() {
|
|||||||
println!("Panic: {}", msg);
|
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.");
|
eprintln!("Error: OPENAI_API_KEY environment variable not set. The application will not function without it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user