grep

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: 0BSD Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Patterns = Registry{
	portname,
	maintainer,
	allDepends,
	buildDepends,
	libDepends,
	runDepends,
	testDepends,
	onlyForArchs,
	uses,
	plist,
	broken,
}
View Source
var Stop = errors.New("stop")

Stop is a special value that can be returned by GrepFunc to indicate that search needs to be terminated early.

Functions

func Grep

func Grep(portsRoot string, categories []string, rxs []*Regexp, rxsOred bool, gfn GrepFunc, maxJobs int) error

Grep searches port Makefiles, looking for matches described by rxs. It starts looking for Makefiles in root directory, and descends up to two levels down (category/port). If cats slice is not empty, Grep descends only to categories listed in cats. By default, multiple regular expressions in rxs are AND-ed together, this can be changed by setting rxsOred to true. The search will be run by using up to jobs goroutines, the usual practice is to set this to runtime.NumCPU() for the best results.

Types

type GrepFunc

type GrepFunc func(path string, res Results, err error) error

GrepFunc is called for each found match and will be passed the path where match was found and a slice of match results. A Special error value Stop can be returned to terminate search early.

type Pattern

type Pattern interface {
	Option() byte
	Description() string
	Compile(ctxBefore, ctxAfter int, quote bool) (*Regexp, error)
	// contains filtered or unexported methods
}

type Regexp

type Regexp struct {
	// contains filtered or unexported fields
}

func Compile added in v1.4.0

func Compile(query string, ctxBefore, ctxAfter int, quote bool) (*Regexp, error)

func (*Regexp) Match

func (r *Regexp) Match(text []byte) (*Result, error)

type Registry added in v1.4.0

type Registry []Pattern

func (Registry) Get added in v1.4.0

func (r Registry) Get(opt byte, query string) Pattern

func (Registry) OptionString added in v1.4.0

func (r Registry) OptionString() string

type Result

type Result struct {
	// Text holds the match as a byte slice
	Text []byte
	// QuerySubmatch is a byte index pair identifying the query submatch in Text
	QuerySubmatch []int
	// QuerySubmatch is a byte index pair identifying the result submatch in Text
	ResultSubmatch []int
}

Result describes one search match result.

func (*Result) String

func (r *Result) String() string

type Results

type Results []*Result

Jump to

Keyboard shortcuts

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