Skip to content

fix(cli): stop watch taking an option's value as the watched path - #1292

Merged
Chemaclass merged 2 commits into
mainfrom
fix/1291-watch-option-values
Aug 17, 2026
Merged

fix(cli): stop watch taking an option's value as the watched path#1292
Chemaclass merged 2 commits into
mainfrom
fix/1291-watch-option-values

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1291

cmd_watch knew only -f/--filter as consuming a value, so every other option's value fell through to the positional branch and became the path being polled. bashunit watch --tag slow tests/ polled a directory named slow and handed the real path to --tag. That case is loud only because of the path validation added in #1263; whenever a value happens to name a real directory, watch polls the wrong one and drops the option silently.

💡 Changes

  • Options may now appear in any position; only a true positional becomes the path
  • The set of value-taking options lives in one shared predicate instead of a second hardcoded list that can drift out of step with cmd_test
  • An anti-drift test derives the expected set from cmd_test's own parser — an option takes a value there precisely when its case arm ends in an unconditional shift — and checks both directions, so neither a new option nor a removed one can slip through. Mutation-tested: dropping --tag and adding a bogus entry each fail it by name
  • Docs drop the "put the path first" caveat

cmd_watch knew only -f/--filter as consuming a value, so every other
option's value fell to the positional branch and became the path.
`bashunit watch --tag slow tests/` polled a directory named slow and handed
the real path to --tag; when a value happened to name a real directory it
polled that one and dropped the option without saying so.

The set of value-taking options now lives in one predicate rather than a
second list that can drift, and a test derives the truth from cmd_test's
own parser -- an option takes a value there precisely when its case arm
ends in an unconditional shift. Both directions are checked, and the guard
is mutation-tested.

Closes #1291
@Chemaclass Chemaclass added the bug Something isn't working label Aug 16, 2026
@Chemaclass Chemaclass self-assigned this Aug 16, 2026
@Chemaclass
Chemaclass merged commit 133323c into main Aug 17, 2026
@Chemaclass
Chemaclass deleted the fix/1291-watch-option-values branch August 17, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant