mirror of
https://github.com/openai/codex.git
synced 2026-11-22 23:00:42 +00:00
feat: support dotenv
This commit is contained in:
@@ -9,11 +9,12 @@ workspace = true
|
||||
[dependencies]
|
||||
clap = { version = "4", features = ["derive", "wrap_help"], optional = true }
|
||||
codex-core = { path = "../core" }
|
||||
dotenvy = { version = "0.15.7", optional = true }
|
||||
toml = { version = "0.9", optional = true }
|
||||
serde = { version = "1", optional = true }
|
||||
|
||||
[features]
|
||||
# Separate feature so that `clap` is not a mandatory dependency.
|
||||
cli = ["clap", "toml", "serde"]
|
||||
cli = ["clap", "dotenvy", "toml", "serde"]
|
||||
elapsed = []
|
||||
sandbox_summary = []
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/// Load env vars from ~/.codex/.env and `$(pwd)/.env`.
|
||||
pub fn load_dotenv() {
|
||||
if let Ok(codex_home) = codex_core::config::find_codex_home() {
|
||||
dotenvy::from_path(codex_home.join(".env")).ok();
|
||||
}
|
||||
dotenvy::dotenv().ok();
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
#[cfg(feature = "cli")]
|
||||
mod approval_mode_cli_arg;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
mod dotenv;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub use dotenv::load_dotenv;
|
||||
|
||||
#[cfg(feature = "elapsed")]
|
||||
pub mod elapsed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user