Documentation
¶
Overview ¶
Package settings owns the unified d9c configuration file (d9c-config.yaml): the single place every persistent setting lives — UI theme and color overrides, normal-mode keybindings, resource-alert thresholds, and the list of saved hosts. Plugins are intentionally NOT here; they stay in their own d9c-plugins.yaml.
This package is the only reader/writer of the file. It delegates validation of each section to the owning package's pure resolver (theme.Resolve, keymap.Resolve, alerts.Resolve), so those packages keep their domain logic without each opening the file independently. Saving rewrites the whole file from the in-memory model, so a host edit can never clobber the theme section and vice versa.
Index ¶
- func DefaultPath() string
- type AlertsSection
- type File
- type Store
- func (s *Store) Alerts() (alerts.Thresholds, error)
- func (s *Store) HasHosts() bool
- func (s *Store) Hosts() *hosts.Store
- func (s *Store) Keymap() (keymap.Map, error)
- func (s *Store) Lang() (i18n.Lang, error)
- func (s *Store) Palette() (styles.Palette, error)
- func (s *Store) Path() string
- func (s *Store) Save() error
- func (s *Store) SetHosts(list []hosts.Host)
- func (s *Store) SetLang(name string) error
- func (s *Store) SetTheme(name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath returns the config file location next to the running binary, falling back to the current directory if the executable path is unavailable.
Types ¶
type AlertsSection ¶
AlertsSection mirrors the "alerts:" block (CPU/MEM thresholds, percent).
type File ¶
type File struct {
Lang string `yaml:"lang,omitempty"`
Theme string `yaml:"theme,omitempty"`
Colors map[string]string `yaml:"colors,omitempty"`
Keys map[string]string `yaml:"keys,omitempty"`
Alerts *AlertsSection `yaml:"alerts,omitempty"`
Hosts []hosts.Host `yaml:"hosts,omitempty"`
}
File is the on-disk shape of d9c-config.yaml. Every section is optional; omitempty keeps a freshly written file free of empty noise.
type Store ¶
type Store struct {
File File
// contains filtered or unexported fields
}
Store is the loaded config bound to its file path.
func Load ¶
Load reads the config file at path. A missing file yields an empty store bound to that path (so a later Save creates it); malformed YAML is an error. The individual sections are validated lazily by Palette/Keymap/Alerts so a single bad section is reported in context.
func (*Store) Alerts ¶
func (s *Store) Alerts() (alerts.Thresholds, error)
Alerts resolves the alert thresholds (disabled when the section is absent).
func (*Store) Hosts ¶
Hosts returns a host store backed by this config file: its CRUD persists by rewriting the unified file (preserving the other sections).
func (*Store) Lang ¶
Lang resolves the configured UI language (default EN when the section is empty or invalid handling is delegated to i18n.Resolve).
func (*Store) Palette ¶
Palette resolves the theme/colors section into a concrete palette (default palette when the section is empty).
func (*Store) SetHosts ¶
SetHosts replaces the host list in-memory without saving. Used by migration before the first explicit Save.