Skip to content

Commit 0cd499b

Browse files
authored
Merge pull request #4 from dotenvx/dotenv-values
add `dotenv_path` and `override` arguments
2 parents 270d7c5 + 3c80747 commit 0cd499b

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5-
## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.2.6...main)
5+
## [Unreleased](https://github.com/dotenvx/python-dotenvx/compare/v0.3.0...main)
6+
7+
## [0.3.0](https://github.com/dotenvx/dotenvx/compare/v0.2.6...v0.3.0)
8+
9+
### Added
10+
11+
* Add `dotenv_path` and `override` arguments ([#4](https://github.com/dotenvx/python-dotenvx/pull/4))
612

713
## [0.2.6](https://github.com/dotenvx/dotenvx/compare/v0.2.5...v0.2.6)
814

src/dotenvx/main.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
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)
@@ -19,10 +25,20 @@ def load_dotenvx():
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)