Skip to content

Commit f66a67f

Browse files
sourcehawkclaude
andcommitted
fix(skills/bounding-heavy-commands): read --check only where an option can stand
The parser took any --check before the '--' as the check option, also when it was the value of another option, such as the name of --exclusive --check. It now skips the value of each option that takes one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2425735 commit f66a67f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎skills/bounding-heavy-commands/scripts/bounded_run.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
PREFIX = "bounded-run"
8282
EXIT_WRAPPER = 125
8383
ACTIVE_VARIABLE = "BOUNDED_RUN_ACTIVE"
84+
VALUE_OPTIONS = ("--memory", "--cpus", "--exclusive", "--measure-rows", "--label")
8485
SLOT_MIB = 2048
8586
MINIMUM_RESERVE_MIB = 2048
8687
MINIMUM_HEADROOM_MIB = 1024
@@ -1054,6 +1055,15 @@ def __init__(self) -> None:
10541055
self.budgets: List[int] = []
10551056

10561057

1058+
def _check_option_given(flags: Sequence[str]) -> bool:
1059+
position = 0
1060+
while position < len(flags):
1061+
if flags[position] == "--check":
1062+
return True
1063+
position += 2 if flags[position] in VALUE_OPTIONS else 1
1064+
return False
1065+
1066+
10571067
def _parse_check(flags: Sequence[str], has_command: bool) -> Options:
10581068
options = Options()
10591069
options.check = True
@@ -1076,7 +1086,7 @@ def parse_arguments(argv: Sequence[str]) -> Options:
10761086
options = Options()
10771087
arguments = list(argv)
10781088
split = arguments.index("--") if "--" in arguments else len(arguments)
1079-
if "--check" in arguments[:split]:
1089+
if _check_option_given(arguments[:split]):
10801090
return _parse_check(arguments[:split], split < len(arguments))
10811091
if "--" not in arguments:
10821092
raise WrapperError("the '--' before the command is missing\n" + USAGE)
@@ -1089,7 +1099,7 @@ def parse_arguments(argv: Sequence[str]) -> Options:
10891099
if flag == "--measure":
10901100
options.measure = True
10911101
continue
1092-
if flag not in ("--memory", "--cpus", "--exclusive", "--measure-rows", "--label"):
1102+
if flag not in VALUE_OPTIONS:
10931103
raise WrapperError("cannot read the option '%s'\n%s" % (flag, USAGE))
10941104
if not flags:
10951105
raise WrapperError("the option '%s' needs a value\n%s" % (flag, USAGE))

‎skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,10 @@ def test_a_command_after_the_check_option_is_a_command_of_a_run(self):
20432043
options = bounded_run.parse_arguments(["--memory", "2G", "--", "tool", "--check"])
20442044
self.assertEqual((options.check, options.command), (False, ["tool", "--check"]))
20452045

2046+
def test_the_value_of_an_option_is_not_the_check_option(self):
2047+
options = bounded_run.parse_arguments(["--exclusive", "--check", "--", "tool"])
2048+
self.assertEqual((options.check, options.exclusive, options.command), (False, ["--check"], ["tool"]))
2049+
20462050
def test_rejects_a_command_and_the_other_options(self):
20472051
for arguments in (
20482052
["--check", "--", "tool"],

0 commit comments

Comments
 (0)