Skip to content

feat(cmd/csvpp/internal/tui): add interactive filter to view command#12

Merged
osamingo merged 4 commits intomainfrom
feat/view-filter
Feb 7, 2026
Merged

feat(cmd/csvpp/internal/tui): add interactive filter to view command#12
osamingo merged 4 commits intomainfrom
feat/view-filter

Conversation

@osamingo
Copy link
Owner

@osamingo osamingo commented Feb 7, 2026

Summary

  • Add vim-like / filter mode to csvpp view TUI with real-time row filtering and column:value syntax support
  • Fix non-deterministic key order in JSON/YAML to CSVPP conversion by preserving parse order
  • Require explicit --from flag when converting stdin to CSVPP to avoid ambiguous format inference

Changes

Filter feature (cmd/csvpp/internal/tui)

  • / key enters filter mode with textinput widget for real-time filtering
  • Case-insensitive substring match across all columns or specific column via column:value
  • Enter commits filter, Esc cancels, selection state preserved across filter changes
  • Extract color palette to package-level variables for readability
  • Add TestParseFilterQuery (10 cases) and TestMatchesFilter (11 cases)

Key order preservation (cmd/csvpp/internal/converter)

  • JSON: Token-based decoder extracts key order from first record
  • YAML: yaml.MapSlice preserves original key order
  • reorderComponents fixes structured field component ordering
  • Tests strengthened with cmp.Diff for exact order verification

stdin format inference (cmd/csvpp)

  • Return error instead of silently defaulting to JSON when --from is unspecified

Test plan

  • GOEXPERIMENT=jsonv2 go test ./cmd/csvpp/... passes
  • GOEXPERIMENT=jsonv2 go vet ./cmd/csvpp/... passes
  • gofumpt -l . reports no changes
  • Manual: csvpp view testdata/validate/valid.csvpp/ filter works

osamingo and others added 3 commits February 7, 2026 18:08
- Add "/" key to enter filter mode with real-time row filtering
- Support "column:value" syntax for column-specific search
- Add case-insensitive substring matching across all columns
- Preserve row selection state using original record indices
- Extract color palette to package-level variables for readability
- Add FilterPrompt and FilterActive styles
- Add textinput dependency for filter input widget
- Add TestParseFilterQuery and TestMatchesFilter test cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove silent default to JSON when input format is ambiguous
- Return explicit error message guiding user to specify --from flag
- Keep CSVPP as default input format when converting to JSON/YAML

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…parsing

- Add keyOrderInfo type for tracking ordered keys with nested structure
- Extract JSON key order using token-based decoder on first record
- Extract YAML key order using yaml.MapSlice for order-preserving decode
- Add reorderComponents to fix structured field component ordering
- Remove non-deterministic collectKeyOrder function
- Strengthen tests with cmp.Diff for exact header and record comparison

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@osamingo osamingo self-assigned this Feb 7, 2026
…t variable declarations

- Remove shadow.Analyzer from csvppvet as err shadowing is idiomatic Go
- Replace `if err = ` with `if err := ` in golden_test.go for consistency

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@osamingo osamingo marked this pull request as ready for review February 7, 2026 09:39
@osamingo osamingo merged commit ccc7afc into main Feb 7, 2026
3 checks passed
@osamingo osamingo deleted the feat/view-filter branch February 7, 2026 09:39
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.

1 participant