config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigPath

func GetConfigPath() (string, error)

GetConfigPath returns the default configuration file path

func IsConfigured

func IsConfigured() bool

IsConfigured checks if the CLI is configured with at least one API key

Types

type APIKeyConfig

type APIKeyConfig struct {
	Key     string `yaml:"key" json:"key"`
	BaseURL string `yaml:"base_url" json:"base_url"`
	Timeout int    `yaml:"timeout,omitempty" json:"timeout,omitempty"` // seconds
}

APIKeyConfig represents configuration for a named API key

type Config

type Config struct {
	DefaultKey string                  `yaml:"default_key,omitempty" json:"default_key,omitempty"`
	Keys       map[string]APIKeyConfig `yaml:"keys" json:"keys"`

	// Global settings
	Verbose bool `yaml:"verbose,omitempty" json:"verbose,omitempty"`
	Debug   bool `yaml:"debug,omitempty" json:"debug,omitempty"`

	// Default values
	DefaultTimeout int    `yaml:"default_timeout,omitempty" json:"default_timeout,omitempty"`
	DefaultBaseURL string `yaml:"default_base_url,omitempty" json:"default_base_url,omitempty"`
}

Config represents the complete CLI configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads configuration from file and environment variables

func NewConfig

func NewConfig() *Config

NewConfig creates a new configuration with defaults

func (*Config) AddKey

func (c *Config) AddKey(name string, key string, baseURL string)

AddKey adds a new API key configuration

func (*Config) GetCurrentKey

func (c *Config) GetCurrentKey() (APIKeyConfig, error)

GetCurrentKey returns the configuration for the currently selected API key

func (*Config) GetCurrentKeyName

func (c *Config) GetCurrentKeyName() string

GetCurrentKeyName returns the name of the currently selected API key

func (*Config) ListKeys

func (c *Config) ListKeys() []string

ListKeys returns a list of configured API key names

func (*Config) RemoveKey

func (c *Config) RemoveKey(name string) error

RemoveKey removes an API key configuration

func (*Config) SaveConfig

func (c *Config) SaveConfig(configPath string) error

SaveConfig saves the configuration to file

func (*Config) SetDefaultKey

func (c *Config) SetDefaultKey(name string) error

SetDefaultKey sets the default API key

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

Jump to

Keyboard shortcuts

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