howmuchleft v0.14.1 /internal/config
On this page

Loads, validates, and caches TOML configuration for progress bar appearance, color gradients, line layout, and profile directories.

#internal/config

#internal/config

#ConfigDir

Go go
const ConfigDir  = "~/.config/howmuchleft"

#ConfigFile

Go go
const ConfigFile = "config.toml"

#Config

Go go
type Config struct

Config holds all configuration fields for howmuchleft.

#ColorEntry

Go go
type ColorEntry struct

ColorEntry defines a gradient with optional conditions.

#LinesConfig

Go go
type LinesConfig struct

LinesConfig defines the content of each output line.

#ConfigPath

Go go
func ConfigPath() string

ConfigPath resolves ~ to the actual home directory and returns the full path.

#DefaultLines

Go go
func DefaultLines() *LinesConfig

DefaultLines returns the default line element configuration used when the user has not customized [lines] in their config.

#Default

Go go
func Default() *Config

Default returns a Config with all default values filled in.

#Load

Go go
func Load(path string) (*Config, error)

Load reads and parses a TOML config file at path. If the file doesn't exist, returns default config (not an error). If the file has parse errors, logs a warning to stderr and returns default config.

#Get

Go go
func Get() *Config

Get returns the cached config, loading it on first call.

#ResetCache

Go go
func ResetCache()

ResetCache clears the cached config (useful for testing).

#OldConfigPath

Go go
func OldConfigPath() string

OldConfigPath returns the path to the legacy JSON config file.

#ConvertJSONToTOML

Go go
func ConvertJSONToTOML() error

ConvertJSONToTOML detects an old JSON config and converts it to TOML. If old exists and new doesn't: converts, writes new, renames old to .bak. If both exist or neither exists: does nothing.

#StripJSONComments

Go go
func StripJSONComments(text string) string

StripJSONComments removes // line comments, / / block comments, and trailing commas before } or ] from JSONC text. Ported from the Node.js implementation in lib/statusline.js.

Search