feat(cli): add watch mode#510
Open
macayu17 wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
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_WATCHflag plumbed throughvalidatorConfig/resolvedConfigand wired intomainInit. - Implements a
watchRunnerusing 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
fsnotifydependency.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #458.
Summary
Adds a
--watchflag 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
fsnotifyis used for cross-platform file watching, as requested in the issue.Verification
go test ./cmd/validator -run 'Test_getFlagsWatchValue|TestRunWatch|Test_emptyBoolEnvVarNoParseError' -count=1go build -o $env:TEMP\validator-watch-test.exe cmd\validator\validator.gogo generate,go vet,gofmt,go build,go test -cover, nested justfile tests91.3%golangci-lint run ./... --timeout=10mgolangci-lint run ./... --timeout=10minpkg/validator/justfilegit diff --checkgit diff --exit-code pkg/filetype/known_files_gen.go