config

package
v0.3.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package config resolves the CLI's runtime configuration from compiled defaults, an optional TOML config file, environment variables, and command-line flags — in that order, with later sources overriding earlier ones.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTOML string

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the config directory path, respecting XDG_CONFIG_HOME on Unix and APPDATA on Windows.

func ConfigFilePath

func ConfigFilePath() string

ConfigFilePath returns the full path to the config file.

func EnsureDefaultConfig

func EnsureDefaultConfig() (bool, error)

EnsureDefaultConfig creates the config directory and writes the default config.toml if it does not already exist. Returns true if the file was created.

Types

type Config

type Config struct {
	APIURL      string       `koanf:"api_url"`
	APIKey      string       `koanf:"api_key"`
	Team        string       `koanf:"team"`
	KeyringURL  string       `koanf:"keyring_url"`
	HTTPTimeout string       `koanf:"http_timeout"`
	Verify      VerifyConfig `koanf:"verify"`
}

Config holds the resolved configuration for the CLI.

func Load

func Load(configPath string, flags *pflag.FlagSet) (*Config, error)

Load reads configuration in priority order: defaults → config file → env → CLI flags. configPath overrides the default config file location if non-empty. flags should be the merged flag set from the executed command (rootFlags for persistent, cmdFlags for command-specific). Only flags that were explicitly set by the user override.

func (Config) Timeout

func (c Config) Timeout() time.Duration

Timeout parses the HTTPTimeout string as a Go duration.

func (*Config) ToTOML

func (c *Config) ToTOML(maskAPIKey bool) string

ToTOML renders the config as a TOML string suitable for display. If the API key is set, it is masked.

type VerifyConfig

type VerifyConfig struct {
	Silent         bool `koanf:"silent"`
	JSON           bool `koanf:"json"`
	SkipExternal   bool `koanf:"skip_external"`
	SkipSignatures bool `koanf:"skip_signatures"`
	Remote         bool `koanf:"remote"`
}

VerifyConfig holds verify-subcommand-specific configuration.

Jump to

Keyboard shortcuts

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