Documentation
¶
Overview ¶
Package envutil provides environment variable helpers with SPROUT_* prefix support.
Index ¶
- func CacheDir() (string, error)
- func ConfigDir() (string, error)
- func DataDir() (string, error)
- func GetConfigDir() (string, error)deprecated
- func GetEnv(suffix string) string
- func GetEnvSimple(suffix string) string
- func HasPrefix(name string) bool
- func HomeDir() (string, error)
- func LookupEnv(suffix string) (string, bool)
- func ResolveColorPreference(want bool) bool
- func SetEnv(suffix, value string) error
- func StateDir() (string, error)
- func StateDirPath() (string, error)
- func UnsetEnv(suffix string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶ added in v0.17.17
CacheDir returns the sprout cache directory path (disposable, regenerable).
Resolution: $SPROUT_CACHE_DIR → $XDG_CACHE_HOME/sprout → $HOME/.cache/sprout.
func ConfigDir ¶ added in v0.17.17
ConfigDir returns the sprout configuration directory path.
Resolution: $SPROUT_CONFIG_DIR → $SPROUT_CONFIG (legacy alias) → $XDG_CONFIG_HOME/sprout → $HOME/.config/sprout.
$SPROUT_CONFIG continues to work as an alias so test isolation and configuration.NewTestManager keep functioning unchanged.
func DataDir ¶ added in v0.17.17
DataDir returns the sprout shared data directory path (regenerable artifacts like embeddings, models).
Resolution: $SPROUT_DATA_DIR → $XDG_DATA_HOME/sprout → $HOME/.local/share/sprout.
func GetConfigDir
deprecated
func GetEnvSimple ¶
GetEnvSimple checks SPROUT_* for a variable name suffix. E.g., GetEnvSimple("CONFIG") checks SPROUT_CONFIG.
func HomeDir ¶ added in v0.19.1
HomeDir resolves the user's home directory, preferring $HOME and falling back to os.UserHomeDir(). Returns ("", error) if neither yields a path. Every resolver in this package must call this so that no resolver panics when $HOME is unset (WASM, minimal sandboxes). Callers comparing against "home" must use this rather than os.UserHomeDir: on Windows the latter reads %USERPROFILE%, which diverges from $HOME under Git Bash/MSYS and from the config roots derived here.
func ResolveColorPreference ¶
ResolveColorPreference applies the no-color.org environment overrides to a caller-supplied preference. SP-048-4a.
Precedence (no-color.org-mandated):
- NO_COLOR set to any non-empty value → colors OFF (always wins)
- FORCE_COLOR set to any non-empty value → colors ON (unless NO_COLOR)
- otherwise → caller's want value
Lives in pkg/envutil because pkg/console directly imports pkg/utils (terminal/string helpers), so pkg/utils importing pkg/console would be a direct two-package cycle. pkg/envutil is the existing zero- dependency leaf used for env-var helpers.
func StateDir ¶ added in v0.17.17
StateDir returns the sprout state directory path (machine-generated, per-install, not portable).
Resolution: $SPROUT_STATE_DIR → $XDG_STATE_HOME/sprout → $HOME/.local/state/sprout.
func StateDirPath ¶ added in v0.17.20
StateDirPath returns the same resolution as StateDir but does not create the directory — for callers whose behavior is gated on existence (registry fallbacks).
Types ¶
This section is empty.