config

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config carries the user-supplied YAML config that any tuilib component can consult. Today only the theme name lives here; as other packages grow user-tunable knobs (logview defaults, runner clear-screen, custom keymaps, custom palettes), their fields land on Config too.

The library never writes the file and never creates the directory — config is opt-in. A missing file is the steady state for users who haven't set anything; Load returns (Config{}, nil) in that case. Parse errors on a malformed file are surfaced so silent corruption doesn't mask itself.

Cross-package usage:

cfg, _ := config.Load()
themes := theme.Resolve(theme.All(), "TUILIB_THEME") // already calls Load
// later, hypothetically:
lvOpts := logview.FromConfig(cfg)                    // reads cfg.Logview

Each consumer pulls just the fields it cares about; this package owns only the file shape and I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the path tuilib will read from. Honors $XDG_CONFIG_HOME, falling back to $HOME/.config/tuilib/config.yaml. The returned path may not exist — callers are expected to stat-and-skip.

Types

type Config

type Config struct {
	// Theme names a theme to use as the initial palette. Matched against
	// theme.Theme.Name by theme.Resolve. Empty string disables the lookup.
	Theme string `yaml:"theme"`
}

Config is the unmarshaled form of $XDG_CONFIG_HOME/tuilib/config.yaml. Unknown YAML keys are tolerated by yaml.Unmarshal so adding new fields is backwards-compatible.

func Load

func Load() (Config, error)

Load reads Path(). When the file doesn't exist, returns (Config{}, nil) — opt-in is the design, so file-not-found is not an error condition.

Returns an error only on permission denied, malformed YAML, or other I/O problems that aren't "file not found".

func LoadFrom

func LoadFrom(path string) (Config, error)

LoadFrom reads a specific path. Same semantics as Load — file-not-found returns (Config{}, nil); other errors propagate. Useful for per-app override paths or tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL