grep

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package grep implements a generic, language-agnostic TOON-emitting search across a project tree, built on the same walker + matcher + enclosing infrastructure as this toolkit's other structural tools. Useful when the AI needs any substring or regex hit (class names, SQL fragments, magic strings) surfaced in a token-cheap, structured form.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `sf grep` Cobra command.

func Run

func Run(opts Options, w io.Writer) error

Run executes the scan and renders the result to w.

Types

type Hit

type Hit struct {
	File      string `json:"file"`
	Line      int    `json:"line"`
	Col       int    `json:"col"`
	Enclosing string `json:"enclosing,omitempty"`
	Text      string `json:"text"`
}

type Options

type Options struct {
	Root          string
	Patterns      []string
	Format        string // "toon" | "md" | "json"
	CaseSensitive bool
	WordBound     bool
	Regex         bool
	Exts          []string // file extensions to include (".php" etc.); empty = all
	ExtraIgnore   []string // extra directory names to skip in addition to defaults
	MaxPerPattern int      // 0 = unlimited
}

type PatternResult

type PatternResult struct {
	Pattern string `json:"pattern"`
	Files   int    `json:"files"`
	Hits    []Hit  `json:"hits"`
}

type Result

type Result struct {
	Patterns []*PatternResult `json:"patterns"`
	Empty    []string         `json:"empty,omitempty"`
	Skipped  int              `json:"skipped,omitempty"` // files skipped: binary or over-long lines
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL