config

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OnlyAll includes all repositories, regardless of state.
	OnlyAll OnlyFilter = "all"

	// OnlyDirty includes repositories that have uncommitted changes or are
	// ahead/behind their upstream.
	OnlyDirty = "dirty"
	// OnlyUncommitted includes repositories with uncommitted files.
	OnlyUncommitted = "uncommitted"
	// OnlyUnpushed includes repositories with local commits not pushed upstream.
	OnlyUnpushed = "unpushed"
	// OnlyUnpulled includes repositories with upstream commits not yet pulled.
	OnlyUnpulled = "unpulled"
)
View Source
const (
	DefaultConfigDir  = "/.config/reposcan/"
	DefaultConfigToml = "config.toml"
	DefaultLogFileDir = "/.config/reposcan/logs/"
)

Default configuration locations under the user's home directory.

Variables

This section is empty.

Functions

func Load

func Load(conf *Config, path string) error

Load reads a TOML configuration file from path into conf.

func WriteToFile

func WriteToFile(config Config, path string) error

WriteToFile serializes config to TOML and writes it to path. Parent directories are created if necessary.

Types

type Config

type Config struct {
	Roots     []string   `toml:"roots,omitempty"`
	DirIgnore []string   `toml:"dirignore,omitempty"`
	Only      OnlyFilter `toml:"only,omitempty"`

	Output Output `toml:"output"`

	// Max git checker workers
	MaxWorkers int `toml:"maxWorkers"`

	// Debug if true, enable logging to a file in [DefaultLogFileDir]
	Debug bool `toml:"debug"`

	Version int `toml:"version"`
}

Config holds all runtime options used by reposcan. Values may come from a config file and/or be overridden by CLI flags.

func CreateOrReadConfigs

func CreateOrReadConfigs(configFilePath string) (Config, error)

CreateOrReadConfigs loads configuration from the user's home directory. If the config file does not exist, it writes a Defaults() config to disk and returns that default configuration.

func Defaults

func Defaults() Config

Defaults returns a Config populated with sensible defaults suitable for typical local development machines.

type Issue

type Issue struct {
	Field   string
	Message string
}

Issue represents a validation warning or error for a configuration field.

type OnlyFilter

type OnlyFilter string

OnlyFilter controls which repositories are included in results based on their cleanliness and remote sync state.

func CreateOnlyFilter

func CreateOnlyFilter(s string) (OnlyFilter, error)

CreateOnlyFilter parses s into an OnlyFilter, returning an error for unrecognized values. Matching is case-insensitive and trims whitespace.

func (OnlyFilter) IsValid

func (f OnlyFilter) IsValid() bool

IsValid reports whether f is a recognized OnlyFilter value.

type Output added in v1.3.0

type Output struct {
	Type            OutputFormat `toml:"type"`
	JSONPath        string       `toml:"jsonPath"`
	ColorSchemeName string       `toml:"colorscheme"`
}

type OutputFormat

type OutputFormat string

OutputFormat controls how scan results are rendered.

const (
	// OutputJson prints a JSON object representing a ScanReport to stdout.
	OutputJson OutputFormat = "json"

	// OutputTable prints a human-readable table to stdout.
	OutputTable OutputFormat = "table"

	OutputInteractive OutputFormat = "interactive"

	// OutputNone suppresses all stdout output.
	OutputNone OutputFormat = "none"
)

func CreateOutputFormat

func CreateOutputFormat(s string) (OutputFormat, error)

CreateOutputFormat parses s into an OutputFormat, returning an error for unrecognized values. Matching is case-insensitive and trims whitespace.

func (OutputFormat) IsValid

func (o OutputFormat) IsValid() bool

IsValid reports whether o is a recognized OutputFormat value.

type Paths

type Paths struct {
	ConfigDir      string
	ConfigFilePath string
	LogFileDir     string
}

Paths contains resolved file-system locations for configuration.

func DefaultPaths

func DefaultPaths() Paths

DefaultPaths returns the default config directory and file path relative to the user's home directory.

type Source

type Source string

Source is a descriptor you might use later when merging; not required today.

const (
	SourceDefaults Source = "defaults"
	SourceFile     Source = "file"
	SourceEnv      Source = "env"
	SourceFlags    Source = "flags"
)

type ValidationResult

type ValidationResult struct {
	Warnings []Issue
	Errors   []Issue
}

ValidationResult aggregates validation warnings and errors discovered while checking a Config value.

func Validate

func Validate(config Config) ValidationResult

Validate checks a Config for common issues such as non-existent roots, invalid enum values, and unusable output paths.

func (*ValidationResult) IsValid

func (v *ValidationResult) IsValid() bool

IsValid reports whether the configuration contains any errors. It returns true when there is at least one error.

func (*ValidationResult) Log added in v1.3.1

func (v *ValidationResult) Log()

func (ValidationResult) Print

func (v ValidationResult) Print()

Print writes warnings and errors to stdout using the stdout renderer.

Jump to

Keyboard shortcuts

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