Documentation
¶
Overview ¶
Package config handles configuration discovery, path resolution, and validation.
Index ¶
- Variables
- func CUEFilesInDir(dir string) ([]string, error)
- func LoadSettingsFromDir(dir string) (map[string]string, error)
- func ResolveAllSettings(paths Paths, localOnly bool) (map[string]SettingEntry, error)
- func SettingDefault(key string) string
- func ValidSettingsKeysString() string
- type Paths
- type Scope
- type SettingEntry
- type SettingInfo
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var SettingsRegistry = map[string]SettingInfo{
"library_index": {Type: "string"},
"default_agent": {Type: "string"},
"shell": {Type: "string"},
"timeout": {Type: "int"},
}
SettingsRegistry defines all valid settings keys and their types.
Functions ¶
func CUEFilesInDir ¶
CUEFilesInDir returns a list of .cue files in the directory.
func LoadSettingsFromDir ¶
LoadSettingsFromDir loads settings from a specific directory.
func ResolveAllSettings ¶
func ResolveAllSettings(paths Paths, localOnly bool) (map[string]SettingEntry, error)
ResolveAllSettings resolves all valid settings with their values and sources.
func SettingDefault ¶
SettingDefault returns the default value for a setting key. Returns empty string if the key has no default.
func ValidSettingsKeysString ¶
func ValidSettingsKeysString() string
ValidSettingsKeysString returns a sorted, comma-separated list of valid setting keys.
Types ¶
type Paths ¶
type Paths struct {
// Global is the path to the global config directory (~/.config/start/).
Global string
// Local is the path to the local config directory (./.start/).
Local string
// GlobalExists indicates whether the global config directory exists.
GlobalExists bool
// LocalExists indicates whether the local config directory exists.
LocalExists bool
}
Paths holds the resolved configuration directory paths.
func ResolvePaths ¶
ResolvePaths discovers configuration directories. workingDir specifies the base directory for local config resolution. If workingDir is empty, the current working directory is used.
type SettingEntry ¶
type SettingEntry struct {
Value string `json:"value"`
Source string `json:"source"` // "default", "global", "local", or "not set"
}
SettingEntry holds a resolved setting value and its source.
type SettingInfo ¶
type SettingInfo struct {
Type string // "string" or "int"
}
SettingInfo describes a valid settings key with its type.
type ValidationResult ¶
type ValidationResult struct {
// GlobalValid indicates the global config directory has valid CUE files.
GlobalValid bool
// LocalValid indicates the local config directory has valid CUE files.
LocalValid bool
// GlobalError contains the validation error for global config, if any.
GlobalError *internalcue.ValidationError
// LocalError contains the validation error for local config, if any.
LocalError *internalcue.ValidationError
}
ValidationResult holds the result of validating configuration directories.
func ValidateConfig ¶
func ValidateConfig(paths Paths) ValidationResult
ValidateConfig validates the CUE configuration in the given paths. It checks each directory that exists for valid CUE files. A directory is considered valid if it contains at least one .cue file that can be successfully parsed and loaded by CUE.
Empty directories (no .cue files) are treated as "no config" rather than errors. Only directories with invalid CUE files produce errors.
func (ValidationResult) AnyValid ¶
func (r ValidationResult) AnyValid() bool
AnyValid returns true if at least one config location is valid.
func (ValidationResult) HasErrors ¶
func (r ValidationResult) HasErrors() bool
HasErrors returns true if there are any validation errors.