diff --git a/scripts/bash/setup-plan.sh b/scripts/bash/setup-plan.sh index 03eaf713b0..f3edb3d9f8 100644 --- a/scripts/bash/setup-plan.sh +++ b/scripts/bash/setup-plan.sh @@ -4,7 +4,6 @@ set -e # Parse command line arguments JSON_MODE=false -ARGS=() for arg in "$@"; do case "$arg" in @@ -18,7 +17,8 @@ for arg in "$@"; do exit 0 ;; *) - ARGS+=("$arg") + echo "ERROR: Unknown option '$arg'" >&2 + exit 1 ;; esac done diff --git a/scripts/powershell/setup-plan.ps1 b/scripts/powershell/setup-plan.ps1 index 52f615aaad..300582d5eb 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.py index d25fdd7829..3b8acc4fd4 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 1 try: 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.py index e8372125a3..d66c7083b3 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