rules

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultRules

func GetDefaultRules() []config.Rule

GetDefaultRules returns the default set of rules Order matters: exclusions, exact matches, globs, directories, catchall

func LoadPackRules

func LoadPackRules(packPath string) ([]config.Rule, error)

LoadPackRules loads pack-specific rules from a pack's .dodot.toml

func LoadPackRulesFS

func LoadPackRulesFS(packPath string, fs types.FS) ([]config.Rule, error)

LoadPackRulesFS loads pack-specific rules from a pack's .dodot.toml using the provided filesystem

func LoadRules

func LoadRules(k *koanf.Koanf) ([]config.Rule, error)

LoadRules loads rules from configuration

func MergeRules

func MergeRules(global, packSpecific []config.Rule) []config.Rule

MergeRules merges pack-specific rules with global rules Pack rules are placed first to take precedence

Types

type FileInfo

type FileInfo struct {
	Path        string // Relative path within pack
	Name        string // Base name
	IsDirectory bool   // Whether this is a directory
}

FileInfo represents a file or directory to be processed

type Match

type Match struct {
	PackName    string                 // Name of the pack
	FilePath    string                 // Relative path within pack
	FileName    string                 // Base name of the file
	IsDirectory bool                   // Whether this is a directory
	Handler     string                 // Handler to process this file
	Options     map[string]interface{} // Handler options from rule
}

Match represents a file matched by a rule

type Matcher

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

Matcher handles the matching of files against rules for packs

func NewMatcher

func NewMatcher() *Matcher

NewMatcher creates a new rule matcher

func (*Matcher) GetMatches

func (m *Matcher) GetMatches(packs []types.Pack) ([]RuleMatch, error)

GetMatches scans packs and returns all rule matches using the rule system

func (*Matcher) GetMatchesFS

func (m *Matcher) GetMatchesFS(packs []types.Pack, fs types.FS) ([]RuleMatch, error)

GetMatchesFS scans packs and returns all rule matches using the rule system with a custom filesystem This function is used for testing and commands that need to use a different filesystem

type ProcessorHandler

type ProcessorHandler interface {
	// ProcessFiles modifies the file list before normal matching
	ProcessFiles(files []FileInfo, packPath string) ([]FileInfo, error)
}

ProcessorHandler runs before normal handlers to modify file list

type RuleMatch

type RuleMatch struct {
	// RuleName is the pattern that matched this file
	RuleName string

	// Pack is the name of the pack containing the matched file
	Pack string

	// Path is the relative path within the pack
	Path string

	// AbsolutePath is the absolute path to the file
	AbsolutePath string

	// Metadata contains any additional data about the matched file
	Metadata map[string]interface{}

	// HandlerName is the name of the handler that should process this match
	HandlerName string

	// HandlerOptions contains options to pass to the handler
	HandlerOptions map[string]interface{}

	// Priority determines the order of processing (higher = processed first)
	Priority int
}

RuleMatch represents a successful rule match on a file or directory This is the output from the rules system that gets passed to handlers

type Scanner

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

Scanner scans packs and applies rules to find matches

func NewScanner

func NewScanner(rules []config.Rule) *Scanner

NewScanner creates a new scanner with the given rules

func NewScannerWithFS

func NewScannerWithFS(rules []config.Rule, fs types.FS) *Scanner

NewScannerWithFS creates a new scanner with the given rules and filesystem

func (*Scanner) ScanPack

func (s *Scanner) ScanPack(pack types.Pack) ([]Match, error)

ScanPack scans a single pack and returns all matches

Jump to

Keyboard shortcuts

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