config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ContentDefaults ContentDefaults `yaml:"content_defaults"`
	Patterns        []Pattern       `yaml:"patterns"`
}

Config represents the complete miso configuration structure. It defines how files are matched and which review guides are applied.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a configuration with sensible defaults. Used when no configuration file is found or as a base for new configurations.

type ContentDefaults

type ContentDefaults struct {
	Strategy string `yaml:"strategy"` // first_lines, full_file, smart
	Lines    int    `yaml:"lines"`    // For first_lines strategy
}

ContentDefaults defines global defaults for content scanning strategies. These settings apply when patterns don't specify their own content strategy.

type Parser

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

Parser handles configuration file parsing and validation. It supports multiple configuration file formats and locations.

func NewParser

func NewParser() *Parser

NewParser creates a new configuration parser with default search paths. The parser will look for configuration files in standard locations.

func (*Parser) FindConfigFile

func (p *Parser) FindConfigFile() (string, error)

FindConfigFile searches for a configuration file in the current directory and parent directories. Returns the path to the first configuration file found, or an error if none found.

func (*Parser) Load

func (p *Parser) Load() (*Config, error)

Load attempts to load configuration from default locations. Returns the first valid configuration found, or default config if none found.

func (*Parser) LoadFile

func (p *Parser) LoadFile(path string) (*Config, error)

LoadFile loads and validates configuration from a specific file path. Returns an error if the file doesn't exist, is invalid YAML, or fails validation.

func (*Parser) LoadFromString

func (p *Parser) LoadFromString(yamlContent string) (*Config, error)

LoadFromString loads configuration from a YAML string. Useful for GitHub Actions or other scenarios where config is provided as a string.

type Pattern

type Pattern struct {
	Name            string   `yaml:"name"`
	Filename        string   `yaml:"filename"`         // Regex for filename matching
	Content         string   `yaml:"content"`          // Regex for content matching
	ContentStrategy string   `yaml:"content_strategy"` // Override default strategy
	ContentLines    []int    `yaml:"content_lines"`    // For smart strategy: [first, last, random]
	Context         []string `yaml:"context"`          // Guide files to use
	DiffContext     []string `yaml:"diff_context"`     // Guide files for diff reviews
	Stop            bool     `yaml:"stop"`             // Stop evaluating further patterns
}

Pattern defines a file matching rule and associated review guides. Patterns are evaluated in order and can match based on filename, content, or both.

Jump to

Keyboard shortcuts

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