feat(config): add typed module-input fields with defaults
This commit is contained in:
@@ -14,12 +14,50 @@ import (
|
||||
//go:embed defaults.yaml
|
||||
var defaultsYAML []byte
|
||||
|
||||
type Packages struct {
|
||||
Base []string `yaml:"base"`
|
||||
}
|
||||
type ArduinoCLIConfig struct {
|
||||
Version string `yaml:"version"`
|
||||
URL string `yaml:"url"`
|
||||
Cores []string `yaml:"cores"`
|
||||
}
|
||||
type ZshPlugin struct {
|
||||
Name string `yaml:"name"`
|
||||
Repo string `yaml:"repo"`
|
||||
}
|
||||
type ZshConfig struct {
|
||||
OhMyZshRepo string `yaml:"oh_my_zsh_repo"`
|
||||
Plugins []ZshPlugin `yaml:"plugins"`
|
||||
}
|
||||
type ZellijConfig struct {
|
||||
ConfigURL string `yaml:"config_url"`
|
||||
}
|
||||
type ThemesConfig struct {
|
||||
Source string `yaml:"source"`
|
||||
}
|
||||
type ShellConfigBlock struct {
|
||||
Name string `yaml:"name"`
|
||||
File string `yaml:"file"`
|
||||
Content string `yaml:"content"`
|
||||
}
|
||||
type ShellConfigSection struct {
|
||||
Blocks []ShellConfigBlock `yaml:"blocks"`
|
||||
}
|
||||
|
||||
// Config is the fully-resolved runtime configuration.
|
||||
type Config struct {
|
||||
Version int `yaml:"version"`
|
||||
ExtraPackages []string `yaml:"extra_packages"`
|
||||
DisabledModules []string `yaml:"disabled_modules"`
|
||||
ThemeOverrides map[string]string `yaml:"theme_overrides"`
|
||||
Version int `yaml:"version"`
|
||||
ExtraPackages []string `yaml:"extra_packages"`
|
||||
DisabledModules []string `yaml:"disabled_modules"`
|
||||
ThemeOverrides map[string]string `yaml:"theme_overrides"`
|
||||
Packages Packages `yaml:"packages"`
|
||||
Fonts []string `yaml:"fonts"`
|
||||
ArduinoCLI ArduinoCLIConfig `yaml:"arduino_cli"`
|
||||
Zsh ZshConfig `yaml:"zsh"`
|
||||
Zellij ZellijConfig `yaml:"zellij"`
|
||||
Themes ThemesConfig `yaml:"themes"`
|
||||
ShellConfig ShellConfigSection `yaml:"shell_config"`
|
||||
}
|
||||
|
||||
const currentVersion = 1
|
||||
@@ -78,5 +116,26 @@ func merge(base, over Config) Config {
|
||||
}
|
||||
out.ThemeOverrides = merged
|
||||
}
|
||||
if len(over.Packages.Base) > 0 {
|
||||
out.Packages = over.Packages
|
||||
}
|
||||
if len(over.Fonts) > 0 {
|
||||
out.Fonts = over.Fonts
|
||||
}
|
||||
if over.ArduinoCLI.Version != "" {
|
||||
out.ArduinoCLI = over.ArduinoCLI
|
||||
}
|
||||
if over.Zsh.OhMyZshRepo != "" {
|
||||
out.Zsh = over.Zsh
|
||||
}
|
||||
if over.Zellij.ConfigURL != "" {
|
||||
out.Zellij = over.Zellij
|
||||
}
|
||||
if over.Themes.Source != "" {
|
||||
out.Themes = over.Themes
|
||||
}
|
||||
if len(over.ShellConfig.Blocks) > 0 {
|
||||
out.ShellConfig = over.ShellConfig
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user