diff --git a/backend/tests/test_configure_script.py b/backend/tests/test_configure_script.py index 6972f6b52d..0551d136f2 100644 --- a/backend/tests/test_configure_script.py +++ b/backend/tests/test_configure_script.py @@ -64,3 +64,38 @@ def test_configure_preserves_existing_configuration(config_checkout: Path, confi assert config_path.read_text(encoding="utf-8") == "existing: true\n" assert not (config_checkout / ".env").exists() assert not (config_checkout / "frontend" / ".env").exists() + + +def test_configure_help_prints_usage_without_generating_files(config_checkout: Path): + result = subprocess.run( + [sys.executable, str(config_checkout / "scripts" / "configure.py"), "--help"], + capture_output=True, + text=True, + encoding="utf-8", + check=False, + timeout=30, + ) + + assert result.returncode == 0, result.stderr + assert "usage: configure.py" in result.stdout + assert "Cross-platform config bootstrap script for DeerFlow." in result.stdout + assert not (config_checkout / "config.yaml").exists() + assert not (config_checkout / ".env").exists() + assert not (config_checkout / "frontend" / ".env").exists() + + +def test_configure_rejects_unknown_flags_without_generating_files(config_checkout: Path): + result = subprocess.run( + [sys.executable, str(config_checkout / "scripts" / "configure.py"), "--not-a-real-flag"], + capture_output=True, + text=True, + encoding="utf-8", + check=False, + timeout=30, + ) + + assert result.returncode == 2 + assert "unrecognized arguments" in result.stderr + assert not (config_checkout / "config.yaml").exists() + assert not (config_checkout / ".env").exists() + assert not (config_checkout / "frontend" / ".env").exists() diff --git a/scripts/configure.py b/scripts/configure.py index ae7e25ecce..25e58fc817 100644 --- a/scripts/configure.py +++ b/scripts/configure.py @@ -3,6 +3,7 @@ from __future__ import annotations +import argparse import shutil import sys from pathlib import Path @@ -17,7 +18,13 @@ def copy_if_missing(src: Path, dst: Path) -> None: shutil.copyfile(src, dst) -def main() -> int: +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser( + prog="configure.py", + description="Cross-platform config bootstrap script for DeerFlow.", + ) + parser.parse_args(argv) + project_root = Path(__file__).resolve().parent.parent existing_config = [