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 ¶
const ( // EnvPrefix is the prefix for environment-variable overrides. EnvPrefix = "GSKILL_" // EnvConfigDir overrides the configuration directory, and with it the // discovered user config file. It is the escape hatch on a machine where // the platform convention cannot be resolved. EnvConfigDir = EnvPrefix + "CONFIG_DIR" )
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
CacheDir returns the gskill cache directory, honoring GSKILL_CACHE_DIR and otherwise following the platform convention.
func DefaultMap ¶
DefaultMap returns the built-in configuration defaults.
func Dir ¶
Dir returns the gskill configuration directory, honoring GSKILL_CONFIG_DIR and otherwise following the platform convention.
func ParseFlexDuration ¶ added in v0.4.0
ParseFlexDuration parses a duration that may use a whole-day suffix ("30d") in addition to the standard time.ParseDuration units. Negative durations are rejected.
func UserFile ¶ added in v0.7.2
UserFile returns the discovered user configuration file: config.toml inside the configuration directory. It is the path `gskill config list` reports, and the source of the user layer whenever --config names nothing else (spec 026 FR-004). The file need not exist; absence is normal and skipped.
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.
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, which is right for a path this package
// discovered on the caller's behalf — absence is the normal case.
//
// RequireUserFile reverses that for UserFile alone: a path the *user*
// named (gskill --config) is a statement of intent, so a missing one is an
// error rather than a silent no-op (spec 026 FR-003). ProjectFile has no
// equivalent because nothing names it explicitly.
UserFile string
RequireUserFile bool
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.