config

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config resolves gskill's layered configuration. Precedence, lowest to highest, is: built-in defaults, user config file, project config file, GSKILL_-prefixed environment variables, then explicit flags. Storage paths follow the platform convention (XDG on Linux, the OS equivalents elsewhere) and may be overridden with GSKILL_CONFIG_DIR / GSKILL_CACHE_DIR.

Index

Constants

View Source
const (
	// EnvPrefix is the prefix for environment-variable overrides.
	EnvPrefix = "GSKILL_"
)

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() (string, error)

CacheDir returns the gskill cache directory, honoring GSKILL_CACHE_DIR and otherwise following the platform convention.

func DefaultMap

func DefaultMap() map[string]any

DefaultMap returns the built-in configuration defaults.

func Dir

func Dir() (string, error)

Dir returns the gskill configuration directory, honoring GSKILL_CONFIG_DIR and otherwise following the platform convention.

func ParseFlexDuration added in v0.4.0

func ParseFlexDuration(s string) (time.Duration, error)

ParseFlexDuration parses a duration that may use a whole-day suffix ("30d") in addition to the standard time.ParseDuration units. Negative durations are rejected.

Types

type Config

type Config struct {
	LogLevel  string
	LogFormat string
	Offline   bool
	NoCache   bool
	Jobs      int
	// Repositories are the known skill repositories an unscoped `find` searches
	// (FR-038). Configured in a config file (TOML array) or via
	// GSKILL_REPOSITORIES (comma-separated).
	Repositories []string
	// StoreLockTimeout bounds how long a contended project mutate lock is
	// waited on before failing. (The key name predates spec 022 and is kept
	// unchanged so existing configs keep working.)
	StoreLockTimeout time.Duration
}

Config is the resolved, layered gskill configuration.

func Default added in v0.4.0

func Default() *Config

Default returns the built-in defaults as a resolved Config, with no file, environment, or flag layers consulted.

func Load

func Load(s Sources) (*Config, error)

Load merges the configuration layers in Sources and returns the result.

type Sources

type Sources struct {
	// Defaults seeds the lowest layer. When nil, DefaultMap is used.
	Defaults map[string]any
	// UserFile and ProjectFile are optional TOML config paths. A missing file
	// is skipped without error.
	UserFile    string
	ProjectFile string
	// ProjectMap is the project layer supplied in memory rather than as a
	// file: skills.toml holds project configuration inside its [config] table
	// alongside skill declarations, so the manifest hands over just that
	// sub-table (spec 023 FR-002). It shares the project layer's precedence
	// slot with ProjectFile — above the user file, below environment and flags.
	ProjectMap map[string]any
	// Environ is a list of "KEY=VALUE" entries (as from os.Environ); only
	// GSKILL_-prefixed entries are consulted. When nil, the process environment
	// is used.
	Environ []string
	// Flags is the highest-precedence layer of explicitly set flag values.
	Flags map[string]any
}

Sources are the inputs to Load. Empty fields are skipped; later layers override earlier ones in the documented precedence order.

Jump to

Keyboard shortcuts

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