config

package
v0.2.26 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides global application configuration management. This only contains CLI display preferences. All HTTP behavior settings are stored per-session in session config files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetViperDefaults added in v0.2.10

func SetViperDefaults(v *viper.Viper)

SetViperDefaults sets default values in a viper instance based on DefaultConfig. This should be used by cmd/root.go to avoid duplicating default values.

Types

type Config

type Config struct {
	// Display settings (CLI preferences)
	PreviewOption string `json:"previewOption" mapstructure:"previewOption"` // full, headers, body, exchange
	ShowColors    bool   `json:"showColors" mapstructure:"showColors"`
	// contains filtered or unexported fields
}

Config represents the global application configuration. This only contains CLI display preferences. All HTTP behavior settings are stored per-session in session config files.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a new config with default values

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads configuration from the default path using Viper

func LoadConfigFromDir

func LoadConfigFromDir(dir string) (*Config, error)

LoadConfigFromDir loads configuration from a specific directory using Viper

func LoadConfigFromFile

func LoadConfigFromFile(filePath string) (*Config, error)

LoadConfigFromFile loads configuration from a specific file path

func LoadOrCreateConfig

func LoadOrCreateConfig() (*Config, error)

LoadOrCreateConfig loads existing config or creates a new one with defaults

func (*Config) BindFlags

func (c *Config) BindFlags(v *viper.Viper)

BindFlags binds cobra flags to viper configuration

func (*Config) ExportToJSON

func (c *Config) ExportToJSON() (string, error)

ExportToJSON exports the config as JSON string

func (*Config) GetViper

func (c *Config) GetViper() *viper.Viper

GetViper returns the underlying viper instance

func (*Config) Reload

func (c *Config) Reload() error

Reload reloads the configuration from the config file

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to file

func (*Config) WatchConfig

func (c *Config) WatchConfig(onChange func())

WatchConfig enables live config reloading

Jump to

Keyboard shortcuts

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