Skip to content

Add --only flag for file filtering#11

Merged
umputun merged 2 commits intomasterfrom
only-filter
Apr 3, 2026
Merged

Add --only flag for file filtering#11
umputun merged 2 commits intomasterfrom
only-filter

Conversation

@umputun
Copy link
Copy Markdown
Owner

@umputun umputun commented Apr 3, 2026

Summary

  • Add repeatable --only/-F flag to filter which files revdiff shows
  • Matches by exact path or path suffix (e.g. --only=model.go matches ui/model.go)
  • Shows "no files match --only filter" message when nothing matches
  • Integrates with single-file mode (if filter results in 1 file, tree pane hides)
  • Plugin skill updated to document --only support, version bumped to 0.2.2

Add repeatable --only/-F flag to show only matching files in the diff
view. Matches by exact path or path suffix. Shows message when no files
match the filter. Bump plugin version to 0.2.2.
Copilot AI review requested due to automatic review settings April 3, 2026 23:50
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

Adds a repeatable --only/-F CLI flag to filter the file list shown in the revdiff TUI, supporting exact-path and path-suffix matching and handling the “no matches” case.

Changes:

  • Add --only/-F option wiring from CLI (cmd/revdiff) into the UI model config.
  • Implement file filtering in ui.Model and integrate it with single-file mode behavior.
  • Update README + Claude plugin skill/docs and bump plugin version to 0.2.2.

Reviewed changes

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

Show a summary per file
File Description
ui/model.go Stores Only filter patterns, filters loaded file lists, and renders a no-match message.
ui/model_test.go Adds unit tests for the filterOnly helper.
cmd/revdiff/main.go Adds --only/-F flag and passes it into ui.ModelConfig.
README.md Documents the new flag and provides usage examples.
.claude-plugin/skills/revdiff/SKILL.md Updates skill docs to mention --only.
.claude-plugin/skills/revdiff/scripts/launch-revdiff.sh Updates usage comment to include --only.
.claude-plugin/skills/revdiff/references/usage.md Adds usage examples for --only.
.claude-plugin/skills/revdiff/references/config.md Adds --only to the config/flags reference table.
.claude-plugin/plugin.json Bumps plugin version to 0.2.2.
.claude-plugin/marketplace.json Bumps marketplace version to 0.2.2.

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

NoStatusBar bool // hide the status bar
NoConfirmDiscard bool // skip confirmation prompt when discarding annotations
Wrap bool // enable line wrapping
Wrap bool // enable line wrapping
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

ModelConfig.Wrap has extra spacing before the comment (bool // ...), which is inconsistent with gofmt output in the rest of the file. Running gofmt (or adjusting the spacing) will keep the struct formatting consistent.

Suggested change
Wrap bool // enable line wrapping
Wrap bool // enable line wrapping

Copilot uses AI. Check for mistakes.
ui/model.go Outdated
NoConfirmDiscard bool // skip confirmation prompt when discarding annotations
Wrap bool // enable line wrapping
Wrap bool // enable line wrapping
Only []string // show only these files (filter by path suffix)
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The Only field comment says it filters "by path suffix", but filterOnly also supports exact path matches (f == pattern). Consider updating the comment to reflect both exact-path and suffix matching to avoid misleading callers.

Suggested change
Only []string // show only these files (filter by path suffix)
Only []string // show only these files (match by exact path or path suffix)

Copilot uses AI. Check for mistakes.
Comment on lines +466 to +469
files := m.filterOnly(msg.files)
if len(files) == 0 && len(m.only) > 0 {
m.viewport.SetContent("no files match --only filter")
return m, nil
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The new --only no-match behavior ("no files match --only filter") isn’t covered by tests. Adding a test that sets m.only, sends a filesLoadedMsg with non-matching files, and asserts viewport content + no auto-select cmd would prevent regressions.

Copilot uses AI. Check for mistakes.
README.md Outdated
| `--wrap` | Enable line wrapping in diff view, env: `REVDIFF_WRAP` | `false` |
| `--no-confirm-discard` | Skip confirmation when discarding annotations with Q, env: `REVDIFF_NO_CONFIRM_DISCARD` | `false` |
| `--chroma-style` | Chroma color theme for syntax highlighting, env: `REVDIFF_CHROMA_STYLE` | `catppuccin-macchiato` |
| `-F`, `--only` | Show only these files, may be repeated (e.g. `--only=model.go --only=README.md`) | |
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The README documents --only as "Show only these files", but the implementation matches both exact paths and path suffixes (e.g. --only=model.go matches ui/model.go). Consider mentioning the suffix/exact matching behavior here for clarity and to align with the actual semantics.

Suggested change
| `-F`, `--only` | Show only these files, may be repeated (e.g. `--only=model.go --only=README.md`) | |
| `-F`, `--only` | Show only matching files (exact paths or path suffixes), may be repeated (e.g. `--only=model.go --only=README.md`) | |

Copilot uses AI. Check for mistakes.
@umputun umputun merged commit 3b78b45 into master Apr 3, 2026
2 checks passed
@umputun umputun deleted the only-filter branch April 3, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants