Skip to content

feat(cli): add watch mode#510

Open
macayu17 wants to merge 4 commits into
Boeing:mainfrom
macayu17:fix/458-watch-mode
Open

feat(cli): add watch mode#510
macayu17 wants to merge 4 commits into
Boeing:mainfrom
macayu17:fix/458-watch-mode

Conversation

@macayu17
Copy link
Copy Markdown
Contributor

Fixes #458.

Summary

Adds a --watch flag for continuous local validation. It runs a full validation pass on startup, then listens for file create/write/ rename events and revalidates the changed file when it still matches the existing finder filters.

The watcher uses fsnotify, adds watches recursively for the configured search paths, picks up new directories as they are created, and exits cleanly on Ctrl+C.

Dependency note

fsnotify is used for cross-platform file watching, as requested in the issue.

Verification

  • go test ./cmd/validator -run 'Test_getFlagsWatchValue|TestRunWatch|Test_emptyBoolEnvVarNoParseError' -count=1
  • go build -o $env:TEMP\validator-watch-test.exe cmd\validator\validator.go
  • Linux container CI path: go generate, go vet, gofmt, go build, go test -cover, nested justfile tests
  • Coverage: 91.3%
  • golangci-lint run ./... --timeout=10m
  • golangci-lint run ./... --timeout=10m in pkg/validator/justfile
  • git diff --check
  • git diff --exit-code pkg/filetype/known_files_gen.go

Copilot AI review requested due to automatic review settings May 27, 2026 22:19
@macayu17 macayu17 requested a review from a team as a code owner May 27, 2026 22:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a --watch (and CFV_WATCH env var) mode that performs an initial validation pass and then revalidates files when changes are detected via fsnotify.

Changes:

  • New --watch/CFV_WATCH flag plumbed through validatorConfig/resolvedConfig and wired into mainInit.
  • Implements a watchRunner using fsnotify with recursive directory watching and a static-file finder for per-event revalidation.
  • Adds unit tests, docs (CLI flags, env vars, README), and changelog entry; adds fsnotify dependency.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/validator/validator.go Adds watch flag, runWatch/watchRunner implementation, and buildCLIWithFinder helper.
cmd/validator/watch_test.go New tests for initial pass + change re-validation and finder-filtered events.
cmd/validator/validator_test.go Adds --watch flag parsing tests and includes CFV_WATCH in empty-env-var test.
go.mod / go.sum Adds github.com/fsnotify/fsnotify v1.10.1 dependency.
website/docs/reference/cli-flags.md Documents the new -watch flag.
website/docs/reference/environment-variables.md Documents the new CFV_WATCH env var.
README.md Mentions watch mode in features list.
CHANGELOG.md Adds entry for --watch mode (closes #458).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/validator/validator.go Outdated
Comment thread cmd/validator/validator.go Outdated
Comment thread cmd/validator/validator.go
Comment thread cmd/validator/validator.go
@kehoecj kehoecj added OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OSS Community Contribution Contributions from the OSS Community waiting-on-maintainer-review PR is waiting to be reviewed and functionally tested by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "watch" mode for continuous validation

3 participants