Documentation
¶
Overview ¶
Package config manages user preferences stored as JSON5/JSON files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidValue = errors.New("invalid config value")
ErrInvalidValue indicates a config value that fails validation.
View Source
var ErrUnknownKey = errors.New("unknown config key")
ErrUnknownKey indicates an invalid config key.
Functions ¶
func Dir ¶
Dir returns the memelink config directory. Respects XDG_CONFIG_HOME; defaults to $HOME/.config/memelink.
func KnownKeys ¶
func KnownKeys() []string
KnownKeys returns a sorted list of valid config key names.
Types ¶
type Config ¶
type Config struct {
DefaultFormat string `json:"default_format,omitempty"`
DefaultFont string `json:"default_font,omitempty"`
DefaultLayout string `json:"default_layout,omitempty"`
Safe *bool `json:"safe,omitempty"`
AutoCopy *bool `json:"auto_copy,omitempty"`
AutoOpen *bool `json:"auto_open,omitempty"`
Preview *bool `json:"preview,omitempty"`
CacheTTL string `json:"cache_ttl,omitempty"`
}
Config holds user preferences.
func FromContext ¶
FromContext retrieves the Config from the context.
func Load ¶
Load reads config from the JSON5 file at path. Returns an empty Config if the file does not exist.
func (*Config) CacheTTLDuration ¶
CacheTTLDuration parses CacheTTL as a time.Duration. Returns 24h on empty or invalid values.
Click to show internal directories.
Click to hide internal directories.