Documentation
¶
Overview ¶
Package envutil provides environment variable helpers with SPROUT_*/LEDIT_* prefix support. This package has ZERO external dependencies to avoid import cycles.
Index ¶
- func GetConfigDir() (string, error)
- func GetEnv(primaryKey, legacyKey string) string
- func GetEnvSimple(suffix string) string
- func HasPrefix(name string) bool
- func LookupEnv(suffix string) (string, bool)
- func ResolveColorPreference(want bool) bool
- func SetEnv(suffix, value string) error
- func SproutKey(legacyKey string) string
- func UnsetEnv(suffix string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigDir ¶
GetConfigDir returns the sprout configuration directory path. It mirrors the resolution logic used by the configuration package:
- SPROUT_CONFIG / LEDIT_CONFIG environment variable (if set)
- XDG_CONFIG_HOME/sprout
- HOME/.config/sprout
- os.UserHomeDir()/.config/sprout
This lives in envutil (zero external dependencies) so that low-level packages like agent_api can resolve the config directory without importing the configuration package (which would create an import cycle).
func GetEnv ¶
GetEnv checks for an environment variable using the primary (sproutKey) name first, falling back to the legacy (legacyKey) name. If only the legacy name is set, a one-time deprecation warning is printed to stderr.
func GetEnvSimple ¶
GetEnvSimple checks SPROUT_* then LEDIT_* for a variable name suffix. E.g., GetEnvSimple("CONFIG") checks SPROUT_CONFIG then LEDIT_CONFIG.
func LookupEnv ¶
LookupEnv checks SPROUT_* first, then LEDIT_*. Returns the value and whether it was found.
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 depends on pkg/configuration (transitively pkg/utils) so pkg/utils can't import pkg/console without creating a cycle. pkg/envutil is the existing zero-dependency leaf used for env-var helpers.
Types ¶
This section is empty.