config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the configuration directory path

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to config file

func EnsureConfigDir

func EnsureConfigDir() error

EnsureConfigDir creates config directory if it doesn't exist

func Save

func Save(cfg *Config) error

Save writes the configuration to the default config path

func SaveTo

func SaveTo(cfg *Config, path string) error

SaveTo writes the configuration to a specific file path

Types

type APIConfig

type APIConfig struct {
	Key     string `mapstructure:"key" yaml:"key,omitempty"`
	BaseURL string `mapstructure:"base_url" yaml:"base_url"`
}

APIConfig holds API-related configuration

type Config

type Config struct {
	API     APIConfig     `mapstructure:"api" yaml:"api"`
	Display DisplayConfig `mapstructure:"display" yaml:"display"`
}

Config holds all configuration values

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns configuration with sensible defaults

func Load

func Load(cfgFile string) (*Config, error)

Load reads configuration from file, environment, and returns a Config struct

func LoadFrom

func LoadFrom(cfgFile string) (*Config, error)

LoadFrom loads configuration from a specific file path

func (*Config) GetAPIKey

func (c *Config) GetAPIKey() string

GetAPIKey returns the API key with precedence: env > config

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type DisplayConfig

type DisplayConfig struct {
	OutputFormat string `mapstructure:"output_format" yaml:"output_format"`
	Color        bool   `mapstructure:"color" yaml:"color"`
	Units        string `mapstructure:"units" yaml:"units"`
	DateFormat   string `mapstructure:"date_format" yaml:"date_format"`
	TimeFormat   string `mapstructure:"time_format" yaml:"time_format"`
}

DisplayConfig holds display-related configuration

Jump to

Keyboard shortcuts

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