💫 Toolkit to help you get started with SDD or any other process!
fix: reject unknown setup-plan arguments (#4371)
pttydoub9c9403b5f41
diff --git a/scripts/bash/setup-plan.sh b/scripts/bash/setup-plan.shindex 03eaf713b..f3edb3d9f 100644--- a/scripts/bash/setup-plan.sh+++ b/scripts/bash/setup-plan.sh@@ -4,7 +4,6 @@ set -e# Parse command line argumentsJSON_MODE=false-ARGS=()for arg in "$@"; docase "$arg" in@@ -18,7 +17,8 @@ for arg in "$@"; doexit 0;;*)- ARGS+=("$arg")+ echo "ERROR: Unknown option '$arg'" >&2+ exit 1;;esacdonediff --git a/scripts/powershell/setup-plan.ps1 b/scripts/powershell/setup-plan.ps1index 52f615aaa..300582d5e 100644--- a/scripts/powershell/setup-plan.ps1+++ b/scripts/powershell/setup-plan.ps1@@ -20,6 +20,11 @@ if ($Help) {exit 0}+if ($RemainingArgs.Count -gt 0) {+ [Console]::Error.WriteLine("ERROR: Unknown option '$($RemainingArgs[0])'")+ exit 1+}+# Load common functions. "$PSScriptRoot/common.ps1"diff --git a/scripts/python/setup_plan.py b/scripts/python/setup_plan.pyindex d25fdd782..3b8acc4fd 100644--- a/scripts/python/setup_plan.py+++ b/scripts/python/setup_plan.py@@ -42,7 +42,9 @@ def main(argv: list[str] | None = None) -> int:elif arg in {"--help", "-h"}:sys.stdout.write(_help_text(sys.argv[0]))return 0- # Other arguments are accepted and silently ignored, matching setup-plan.sh.+ else:+ print(f"ERROR: Unknown option '{arg}'", file=sys.stderr)+ return 1try:paths = get_feature_paths(script_file=Path(__file__))diff --git a/tests/test_setup_plan_python_parity.py b/tests/test_setup_plan_python_parity.pyindex e8372125a..d66c7083b 100644--- a/tests/test_setup_plan_python_parity.py+++ b/tests/test_setup_plan_python_parity.py@@ -132,7 +132,7 @@ def test_python_existing_plan_matches_bash(repo: Path, args: tuple[str, ...]) ->@requires_bash@pytest.mark.skipif(not HAS_POWERSHELL, reason="no PowerShell available")-def test_all_variants_ignore_extra_arguments(tmp_path: Path) -> None:+def test_all_variants_reject_unknown_options(tmp_path: Path) -> None:repos = [_setup_repo(tmp_path, "bash"),_setup_repo(tmp_path, "powershell"),@@ -143,13 +143,15 @@ def test_all_variants_ignore_extra_arguments(tmp_path: Path) -> None:ps = run(ps_cmd(repos[1], SCRIPT, "-Json", "--bogus"), repos[1])py = run(py_cmd(repos[2], SCRIPT, "--json", "--bogus"), repos[2])- assert bash.returncode == ps.returncode == py.returncode == 0- assert normalize_repo_paths(bash.stdout, repos[0]) == normalize_repo_paths(- ps.stdout, repos[1]- ) == normalize_repo_paths(py.stdout, repos[2])- assert normalize_repo_paths(bash.stderr, repos[0]) == normalize_repo_paths(- ps.stderr, repos[1]- ) == normalize_repo_paths(py.stderr, repos[2])+ assert bash.returncode == ps.returncode == py.returncode == 1+ assert bash.stdout == ps.stdout == py.stdout == ""+ assert bash.stderr == ps.stderr == py.stderr == (+ "ERROR: Unknown option '--bogus'\n"+ )+ assert all(+ not (current / "specs" / "001-my-feature" / "plan.md").exists()+ for current in repos+ )@requires_bash