Documentation
¶
Overview ¶
Package config handles loading, saving, and defining the application's configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConfigNotFound = errors.New("configuration file not found")
ErrConfigNotFound is returned by LoadConfig when no config file is found.
Functions ¶
func SaveConfig ¶
SaveConfig saves the provided configuration to the specified path or the default location. It creates the necessary directories if they don't exist. It returns the path where the file was saved and any error encountered.
Types ¶
type Config ¶
type Config struct {
AgeDays int `toml:"age_days"`
PrimaryMainBranch string `toml:"primary_main_branch"`
ProtectedBranches []string `toml:"protected_branches"`
LastVersionCheck int64 `toml:"last_version_check"` // Unix timestamp of last check
LatestKnownVersion string `toml:"latest_known_version"` // Latest version found during checks
// Internal map for faster lookups, not loaded from TOML directly
ProtectedBranchMap map[string]bool `toml:"-"`
}
Config holds the application configuration settings. Tags correspond to the keys in the TOML configuration file.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config struct with default values.
func FirstRunSetup ¶
FirstRunSetup prompts the user for initial configuration values when no config file is found. It takes an input reader and output writer for flexibility (e.g., testing). It returns the generated Config struct based on user input or defaults.
func LoadConfig ¶
LoadConfig loads configuration from the specified path or the default location. If a custom path is provided and exists, it's used. Otherwise, it checks the default path. If neither exists, it returns default settings and ErrConfigNotFound. It also populates the ProtectedBranchMap.