Add --watch/-w flag to re-run analysis on file changes - #52
Merged
Conversation
Watches the scanned path with FileSystemWatcher, debounces bursts of changes (~400ms), and re-scans/re-analyzes on each settled change, refreshing the same Spectre.Console live table until Ctrl+C. Table format only; rejected together with --git-hash, --list-file, or --baseline since those aren't live filesystem sources.
- Ctrl+C now wakes the debounce wait immediately via a signaled ManualResetEventSlim instead of waiting out a plain Thread.Sleep. - Extract the scan-then-analyze-then-merge-then-dedup logic shared by the one-shot run and each watch pass into a single AnalyzeFiles helper, so the two paths can't drift apart. - Filter out FileSystemWatcher events under well-known build/VCS/ package directories (bin, obj, .git, node_modules, etc.) so editors and build output don't trigger constant rescans.
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.
Summary
--watch/-wflag: watches the scanned path withFileSystemWatcher, debounces bursts of changes (~400ms), and re-scans/re-analyzes on each settled change, refreshing the same live table (Spectre.ConsoleLive) until Ctrl+C.--watchis rejected together with--git-hash,--list-file, or--baselinesince those aren't live filesystem sources.CLAUDE.md,README.mdEN/中文) updated with the new option.Test plan
dotnet build Sloc.slnxdotnet test Sloc.slnxsloc <dir> --watch, edit a file under<dir>, confirm the table refreshes within ~1s; press Ctrl+C to confirm clean exit--watchcombined with--git-hash,--list-file,--baseline, or a non-Table--formatfails with a clear errorGenerated by Claude Code