Documentation
¶
Overview ¶
Package config reads and writes commit-spark's configuration file (~/.csprc, ini format).
Index ¶
Constants ¶
const ( TypePlain = "plain" TypeConventional = "conventional" TypeConventionalBody = "conventional+body" TypeGitmoji = "gitmoji" TypeSubjectBody = "subject+body" )
Valid commit message type values.
Variables ¶
var ConfigKeys = []string{"MODEL", "locale", "type", "timeout", "max-length"}
ConfigKeys is the ordered list of recognized config keys (ini key names).
Functions ¶
func ConfigPath ¶ added in v0.1.0
ConfigPath returns the path to ~/.csprc.
func IsValidKey ¶
IsValidKey reports whether key is one of ConfigKeys.
func ReadRaw ¶ added in v0.1.0
ReadRaw reads the raw ini key-value map. Returns an empty map (not an error) if the file doesn't exist yet.
func SetConfigs ¶ added in v0.1.0
SetConfigs validates and writes key=value pairs to ~/.csprc. An empty value deletes the key. Returns *apperr.KnownError for unrecognized keys.
Types ¶
type Config ¶
type Config struct {
Model string
Locale string
Type string
Timeout int // milliseconds; 0 means "not set"
MaxLength int
}
Config is the fully parsed, validated configuration used at runtime.
func Load ¶
func Load(opts LoadOptions) (Config, error)
Load reads ~/.csprc, applies CLIOverrides, validates/parses each known key, and returns the resulting Config. If the raw config has a "proxy" key, prints a deprecation warning to stderr.
type LoadOptions ¶ added in v0.1.0
type LoadOptions struct {
// CLIOverrides take precedence over the config file for matching keys.
CLIOverrides map[string]string
// SuppressErrors: parse failures are silently ignored (value falls back
// to the key's default) instead of returning an error. Used by `csp
// config` (display mode) so a single bad value doesn't hide everything.
SuppressErrors bool
}
LoadOptions configures Load.