feat: load dotenv in cli entrypoints

This commit is contained in:
lda
2026-06-13 05:58:12 +07:00 Verified
parent 82bc036987
commit 38913cfdcb
4 changed files with 30 additions and 0 deletions
+2
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
from typing import Annotated
import typer
from dotenv import load_dotenv
from .commands import (
admin,
@@ -86,4 +87,5 @@ app.command("status")(status.status_command)
def main() -> None:
"""Console script entrypoint for `wf`."""
load_dotenv()
app()
+2
View File
@@ -4,6 +4,7 @@ from pathlib import Path
import typer
import uvicorn
from dotenv import load_dotenv
from wf_config import (
FilesystemStoreConfig,
@@ -112,4 +113,5 @@ def serve(
def main() -> None:
load_dotenv()
app()
+13
View File
@@ -23,6 +23,19 @@ def test_wf_help_lists_lifecycle_groups() -> None:
assert "explain" in result.output
def test_wf_main_loads_dotenv_before_invoking_app(monkeypatch) -> None:
import wf_cli.app as mod
calls: list[str] = []
monkeypatch.setattr(mod, "load_dotenv", lambda: calls.append("dotenv"))
monkeypatch.setattr(mod, "app", lambda: calls.append("app"))
mod.main()
assert calls == ["dotenv", "app"]
def test_wf_run_group_help_exists() -> None:
result = runner.invoke(app, ["run", "--help"])
+13
View File
@@ -17,6 +17,19 @@ def test_rpc_server_cli_help_mentions_store_root() -> None:
assert "--port" in result.output
def test_rpc_server_main_loads_dotenv_before_invoking_app(monkeypatch) -> None:
import wf_server.cli as mod
calls: list[str] = []
monkeypatch.setattr(mod, "load_dotenv", lambda: calls.append("dotenv"))
monkeypatch.setattr(mod, "app", lambda: calls.append("app"))
mod.main()
assert calls == ["dotenv", "app"]
def test_rpc_server_cli_accepts_config_file(tmp_path) -> None:
config_path = tmp_path / "wf.json"
config_path.write_text(