Skip to content

Add eko search command to search file contents across snapshots #110

Description

@kavix

🎯 Goal

Implement an eko search <pattern> command that performs a text search across all files in a given snapshot (or all snapshots) and reports matching file paths and line numbers, similar to grep -r but scoped to Eko snapshots.

💡 Expected Usage

# Search for a string in the latest snapshot
eko search "TODO"

# Search in a specific snapshot
eko search "TODO" --snapshot 8c9d1a2f

# Search across all snapshots
eko search "deprecated" --all

🛠️ Implementation Steps

  1. Create cmd/search.go with Cobra command searchCmd.
  2. Walk .eko/snapshots/<id>/ file tree and use bufio.Scanner to search each text file for the pattern (skip binaries using heuristics).
  3. Print matching file path, line number, and surrounding context (like grep -n).
  4. Support --all flag to iterate over all snapshot IDs from the DB.
  5. Add unit tests in cmd/commands_test.go.

📖 See full details in GOOD_FIRST_ISSUES.md — Issue #16
🌟 Great for first-time contributors! Read CONTRIBUTING.md to get started.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions