Skip to content

Commit 238531f

Browse files
committed
add dotenv_path and override arguments
1 parent 270d7c5 commit 238531f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/dotenvx/main.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,37 @@
88

99
ERROR_MISSING_BINARY = "[MISSING_BINARY] missing dotenvx binary\n[MISSING_BINARY] https://github.com/dotenvx/dotenvx/issues/576"
1010

11-
def load_dotenvx():
12-
output = get()
11+
def load_dotenvx(
12+
dotenv_path=None,
13+
override=False
14+
):
15+
output = dotenvx_get(
16+
dotenv_path=dotenv_path,
17+
override=override
18+
)
1319

1420
try:
1521
parsed = json.loads(output)
1622
for key, value in parsed.items():
1723
os.environ[key] = value
18-
return parsed
24+
return True
1925
except Exception as e:
2026
raise RuntimeError(f"Failed to parse dotenvx output: {e}")
2127

22-
def get():
28+
def dotenvx_get(
29+
dotenv_path=None,
30+
override=False
31+
):
2332
binpath = binary()
33+
cmd = [binpath, "get", "-pp"]
34+
35+
if dotenv_path:
36+
cmd += ["-f", dotenv_path]
37+
if override:
38+
cmd.append("--overload")
39+
2440
output = subprocess.run(
25-
[binpath, "get", "-pp"],
41+
cmd,
2642
capture_output=True,
2743
text=True,
2844
check=True

0 commit comments

Comments
 (0)