Documentation
¶
Overview ¶
Package config reads and writes the user's persistent preferences: ~/.config/cais/config.yaml (or $XDG_CONFIG_HOME if set).
The config file is a small YAML document:
theme: cais-dusk
More fields will land later (default file, keybinding overrides — see docs/ROADMAP.md). The struct and the write path are designed to absorb them without changing existing callers: Add a field, tag it, and LoadConfig/SaveConfig round-trip it automatically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveConfig ¶
SaveConfig writes cfg to the config file, creating the directory if needed. It is the whole persistence story for now: one call after a theme is chosen, one file, one write.
Types ¶
type Config ¶
type Config struct {
// Theme is the registered theme name to activate on startup.
// Empty means "use appstyles.DefaultTheme".
Theme string `yaml:"theme,omitempty"`
// URLHost overrides the host part of every service URL the app builds
// (utils.URLHost). Empty means "detect it" - SSH_CONNECTION's server
// address when running over SSH, "localhost" otherwise.
URLHost string `yaml:"url_host,omitempty"`
}
Config is the persistent user preferences. Fields are exported for YAML marshalling; the zero value of each is the "not set" sentinel, and LoadConfig leaves a missing field at its zero rather than erroring.
func LoadConfig ¶
LoadConfig reads the config file and returns the parsed Config. A missing file is not an error: it returns the zero Config and a nil error, so the caller can apply defaults (DefaultTheme) without special-casing "first run". A malformed file is an error worth reporting — the caller decides whether to surface it or fall back to defaults.
type MigrateResult ¶
type MigrateResult struct {
// Migrated is true if the legacy directory was found and renamed into
// place under the new appDir. False means there was nothing to do.
Migrated bool
// From and To are the directories involved in the migration. From is
// empty when the legacy directory did not exist on startup.
From, To string
// ThemeRenamed is true if a stitcher-* theme in config.yaml was
// rewritten to a cais-* equivalent during the migration.
ThemeRenamed bool
// Warning is non-empty when both legacy and new directories exist on
// startup. Neither is touched in that case — the user has to decide.
Warning string
}
MigrateResult reports what MigrateLegacyConfig did on its one-shot run. The CLI/TUI surfaces the migrated message once on its first run.
func MigrateLegacyConfig ¶
func MigrateLegacyConfig() (MigrateResult, error)
MigrateLegacyConfig performs a one-shot, first-launch migration from the previous-identity "stack-stitcher" config directory to "cais".
The rules:
- legacy dir absent → no-op (first-time install).
- new dir already exists → no-op + warning. The user has both directories; Cais must not delete or overwrite either.
- legacy dir present, new dir absent → rename legacy→new; rewrite any `theme: stitcher-*` line in config.yaml to its cais-* equivalent. The DB file (if any) is renamed along with the dir.
The result struct reports what happened so a caller can surface a one-time notice. MigrateLegacyConfig is safe to call repeatedly; once the legacy dir is gone, it returns Migrated=false silently.