Documentation
¶
Overview ¶
Package config loads, saves, and validates lore's TOML config file.
On-disk paths are stored with `~/` so the file is portable across machines (e.g. synced via dotfiles). In-memory Config always holds absolute paths; expansion happens once at Load and Save handles contraction on the way out.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contract ¶
Contract is the inverse of Expand: if p is under HOME, rewrite the prefix back to `~`. Otherwise returns p unchanged. Best-effort: on any error determining HOME, returns p unchanged.
func DefaultConfigTOML ¶
func DefaultConfigTOML() []byte
DefaultConfigTOML returns the embedded commented template byte-for-byte. Used by callers (tests, future `lore reset` etc.) that need the raw file.
func Expand ¶
Expand resolves a leading `~/` to the user's home directory. A bare `~` also expands. Returns p unchanged if it doesn't start with `~`.
func Path ¶
Path returns the on-disk location of the config file. Honors XDG_CONFIG_HOME; falls back to ~/.config/lore/config.toml.
func Save ¶
Save writes cfg to disk. Path fields are contracted back to `~/...` form. Comments from the embedded template are NOT preserved; this round-trip path is for programmatic config edits in later slices. Slice 1 uses WriteDefaults to lay down the commented template instead.
func WriteDefaults ¶
func WriteDefaults() error
WriteDefaults writes the embedded commented template verbatim to the config file location. Returns CodeConflict if the file already exists; the caller is responsible for the higher-level "already configured" check.
On any failure after the file is opened (write error, sync error), the partial file is removed so a retry isn't permanently blocked by the O_EXCL guard. ENOSPC mid-write is the motivating real-world case.
Types ¶
type CommitConfig ¶
type CommitConfig struct {
Auto bool `toml:"auto"`
AddTemplate string `toml:"add_template"`
RmTemplate string `toml:"rm_template"`
MvTemplate string `toml:"mv_template"`
SyncTemplate string `toml:"sync_template"`
}
CommitConfig holds commit-related preferences.
type Config ¶
type Config struct {
CentralRepo string `toml:"central_repo"`
ProjectsRoots []string `toml:"projects_roots"`
ProjectsDepth int `toml:"projects_root_depth"`
AgentDirs []string `toml:"agent_dirs"`
Commit CommitConfig `toml:"commit"`
}
Config is the typed representation of ~/.config/lore/config.toml.