grep

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(args []string) error

Types

type Config

type Config struct {
	Pattern          string `flag:"" desc:"Search pattern (regex or literal)"`
	Recursive        bool   `flag:"" desc:"Search recursively in directories"`
	LineNumbers      bool   `flag:"" desc:"Show line numbers"`
	FilesWithMatches bool   `flag:"" desc:"Show only file names with matches"`
	CaseInsensitive  bool   `flag:"" desc:"Case insensitive search"`
	WordMatch        bool   `flag:"" desc:"Match whole words only"`
	AfterContext     int    `flag:"" desc:"Number of context lines after match"`
	BeforeContext    int    `flag:"" desc:"Number of context lines before match"`
	ContextLines     int    `flag:"" desc:"Number of context lines around match"`
	CountOnly        bool   `flag:"" desc:"Count matches only, don't show content"`
	InvertMatch      bool   `flag:"" desc:"Invert match - show non-matching lines"`
	ExtendedRegex    bool   `flag:"" desc:"Use extended regular expressions"`
	FixedStrings     bool   `flag:"" desc:"Treat pattern as literal string"`
	Include          string `flag:"" desc:"Include files matching pattern (e.g., *.go)"`
	ExcludeDir       string `flag:"" desc:"Exclude directories matching pattern"`
	MaxCount         int    `flag:"" desc:"Stop after N matches"`
	XML              bool
	JSON             bool
	Plain            bool
	Pretty           bool
}

type GrepError

type GrepError struct {
	XMLName xml.Name `xml:"error"`
	Code    int      `xml:"code,attr"`
	Msg     string   `xml:"msg,attr"`
	Path    string   `xml:"path,attr"`
}

type GrepFileMatch

type GrepFileMatch struct {
	XMLName       xml.Name    `xml:"file"`
	Path          string      `xml:"path,attr"`
	Absolute      string      `xml:"absolute,attr"`
	Language      string      `xml:"language,attr"`
	MatchesInFile int         `xml:"matches_in_file,attr"`
	Lines         []GrepMatch `xml:"line"`
}

type GrepMatch

type GrepMatch struct {
	XMLName     xml.Name `xml:"line"`
	Number      int      `xml:"number,attr"`
	Text        string   `xml:"text,attr"`
	OffsetBytes int64    `xml:"offset_bytes,attr"`
	Before      string   `xml:"before,omitempty"`
	After       string   `xml:"after,omitempty"`
}

type GrepResult

type GrepResult struct {
	XMLName       xml.Name        `xml:"grep"`
	Pattern       string          `xml:"pattern,attr"`
	Flags         string          `xml:"flags,attr"`
	Recursive     string          `xml:"recursive,attr"`
	CaseSensitive string          `xml:"case_sensitive,attr"`
	MatchType     string          `xml:"match_type,attr"`
	SearchedFiles int             `xml:"searched_files,attr"`
	MatchedFiles  int             `xml:"matched_files,attr"`
	TotalMatches  int             `xml:"total_matches,attr"`
	SearchRoot    string          `xml:"search_root,attr"`
	Timestamp     int64           `xml:"timestamp,attr"`
	Matches       []GrepFileMatch `xml:"match"`
	Errors        []GrepError     `xml:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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