Skip to content

feat(cli): implement watch command with fsnotify and --json streaming#34

Open
abhinav-1504 wants to merge 3 commits into
optiqor:mainfrom
abhinav-1504:feat/watch-command
Open

feat(cli): implement watch command with fsnotify and --json streaming#34
abhinav-1504 wants to merge 3 commits into
optiqor:mainfrom
abhinav-1504:feat/watch-command

Conversation

@abhinav-1504
Copy link
Copy Markdown

What

Implements optiqor watch [chart] — re-analyzes a Helm chart or
values file whenever a YAML file changes.

Why

Fixes #15

How

  • internal/watch/watch.go — core watch loop using fsnotify; 200ms
    debounce to absorb editor save storms; ANSI screen clear between
    runs when stdout is a TTY; --json streams newline-delimited JSON
    events (start/update/error); SIGINT/SIGTERM → clean exit (code 0)
  • cmd/optiqor/main.go — wired newWatchCmd() to call watch.Run();
    added --json flag; honours --no-color and NO_COLOR
  • Tests use context cancellation instead of OS signals for
    cross-platform compatibility

Testing

  • go test ./internal/... ./pkg/... -timeout 30s — 10/10 PASS
  • go build ./... — clean
  • Tested locally:
    • optiqor watch ./cmd/optiqor/demo/values.yaml → full report, waits
    • optiqor watch ... --json → valid JSON streamed
    • File change → update event emitted
    • Invalid YAML → error event emitted gracefully
    • Ctrl-C → exits with code 0

Note: TestGolden in cmd/optiqor fails on Windows only due to
path separator differences (\ vs /) — pre-existing issue unrelated
to this PR. CI runs on Ubuntu where it passes.

Checklist

  • PR title follows Conventional Commits
  • All commits are DCO-signed
  • No unrelated changes pulled in
  • No LLM calls or telemetry introduced
  • No proprietary backend imports

@abhinav-1504 abhinav-1504 requested a review from btwshivam as a code owner May 21, 2026 10:38
@github-actions
Copy link
Copy Markdown

First PR — welcome aboard!

A few things to expect:

  1. CI: every PR runs build + race tests + lint on Ubuntu and macOS. If something fails, the log will tell you exactly which gate.
  2. DCO: every commit needs Signed-off-by:. git commit -s adds it automatically.
  3. Conventional Commits: PR titles like feat(analyze): new rule or fix(cli): handle X. We squash-merge by default.
  4. Review: a maintainer will review within 72 hours. Suggestions are conversations, not orders — push back if something doesn't fit your context.

If you get stuck, reply here or jump to Discussions. We want this PR to land.

@github-actions github-actions Bot added testing Test coverage and golden fixtures area/cli Cobra CLI commands and UX size/XL 501+ lines (consider splitting) labels May 21, 2026
Signed-off-by: Abhinav Singh Chauhan <abhinavsinghc48@gmail.com>
@abhinav-1504
Copy link
Copy Markdown
Author

Hello @btwshivam,
All CI checks now passing — race condition fixed with mutex-protected safeBuffer, lint issues resolved (nolint explanation, context parameter order, removed unused notYetImplemented).

@abhinav-1504
Copy link
Copy Markdown
Author

Hi @btwshivam, just following up on this PR. All CI checks are passing now and the latest changes have been pushed.

Could you please take another look when possible? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Cobra CLI commands and UX size/XL 501+ lines (consider splitting) testing Test coverage and golden fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement watch command: re-analyze on file change

1 participant