Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/bash/setup-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -e

# Parse command line arguments
JSON_MODE=false
ARGS=()

for arg in "$@"; do
case "$arg" in
Expand All @@ -18,7 +17,8 @@ for arg in "$@"; do
exit 0
;;
*)
ARGS+=("$arg")
echo "ERROR: Unknown option '$arg'" >&2
exit 1
;;
esac
done
Expand Down
5 changes: 5 additions & 0 deletions scripts/powershell/setup-plan.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 3 additions & 1 deletion scripts/python/setup_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
18 changes: 10 additions & 8 deletions tests/test_setup_plan_python_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
Expand Down