Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶ added in v0.1.9
ConfigDir returns the XDG-compliant config directory for desearch-cli. This is the parent directory that contains config.toml and the history/ subdirectory.
func ConfigPath ¶
ConfigPath returns the XDG-compliant config file path.
func GetAPIKey ¶
func GetAPIKey() string
GetAPIKey returns the API key from the environment or config file. Environment variable DESEARCH_API_KEY takes precedence over config file. Returns an empty string if the key cannot be loaded.
func SaveConfig ¶
SaveConfig writes the configuration to the XDG config path. It creates the directory structure if it does not exist and sets permissions to 0600.
Types ¶
type Config ¶
type Config struct {
APIKey string `toml:"api_key" json:"api_key"`
DefaultTools []string `toml:"default_tools" json:"default_tools"`
DefaultDateFilter string `toml:"default_date_filter" json:"default_date_filter"`
DefaultCount int `toml:"default_count" json:"default_count"`
HistoryEnabled bool `toml:"history_enabled" json:"history_enabled"`
}
Config holds the application configuration.
func LoadConfig ¶
LoadConfig reads the configuration from the XDG config path. If the config file does not exist, it returns an empty Config and no error.