config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config reads and writes commit-spark's configuration file (~/.csprc, ini format).

Index

Constants

View Source
const (
	TypePlain            = "plain"
	TypeConventional     = "conventional"
	TypeConventionalBody = "conventional+body"
	TypeGitmoji          = "gitmoji"
	TypeSubjectBody      = "subject+body"
)

Valid commit message type values.

Variables

View Source
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

func ConfigPath() (string, error)

ConfigPath returns the path to ~/.csprc.

func IsValidKey

func IsValidKey(key string) bool

IsValidKey reports whether key is one of ConfigKeys.

func ReadRaw added in v0.1.0

func ReadRaw() (map[string]string, error)

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

func SetConfigs(kvs [][2]string) error

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.

Jump to

Keyboard shortcuts

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