feat: load dotenv in cli entrypoints
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"])
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user