Documentation
¶
Overview ¶
Package config loads the mdp TOML configuration and the small helpers (browser command resolution, fzf picker, extra CSS) that consume it. A missing config file is silent; malformed values produce warnings on the supplied error writer rather than failing the run.
Index ¶
- func BrowserCmd(browser any, url string, lookPath func(string) (string, error), goos string, ...) []string
- func EnsureDefault() error
- func ExpandTilde(p string) string
- func ExtraCSS(cfg Config, errLog io.Writer) string
- func FzfPick(ctx context.Context, cwd string) (string, error)
- func Path() string
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrowserCmd ¶
func BrowserCmd(browser any, url string, lookPath func(string) (string, error), goos string, errLog io.Writer) []string
BrowserCmd builds the argv used to open url. The lookPath and goos arguments are injected so tests don't have to touch the real PATH or runtime.GOOS.
func EnsureDefault ¶
func EnsureDefault() error
EnsureDefault writes a commented default config file to Path() when one does not already exist. Existing files are left untouched. Failures (permission denied, etc.) are non-fatal: callers should ignore the returned error or surface it as a warning.
func ExpandTilde ¶
ExpandTilde replaces a leading "~/" with the user's home directory. Bare "~" and other inputs are returned unchanged.
func ExtraCSS ¶
ExtraCSS builds the CSS string contributed by the user's config. Errors are non-fatal: bad values are reported on errLog and skipped.
Types ¶
type Config ¶
type Config struct {
Theme string `toml:"theme"`
FontSize *float64 `toml:"font_size"`
CustomCSS string `toml:"custom_css"`
Browser any `toml:"browser"`
Edit bool `toml:"edit"`
Colemak bool `toml:"colemak"`
}
Config is the parsed TOML config. Fields use zero values / nil pointers to distinguish "unset" from explicitly-set values where it matters.