MCPcopy Create free account
hub / github.com/diillson/chatcli / envBool

Function envBool

cli/config_sections.go:259–278  ·  view source on GitHub ↗

envBool renders the localized enabled/disabled/default labels for boolean envs (accepts 1/true/yes). When the var is unset and the default registry has a known boolean fallback, the rendered line is the localized enabled/disabled label tagged with defaultMarker so kv() reports e.g. "enabled (default

(name string)

Source from the content-addressed store, hash-verified

257// reports e.g. "enabled (default)" instead of a bare "(default)" with
258// no truth value attached.
259func envBool(name string) string {
260 v := strings.ToLower(strings.TrimSpace(os.Getenv(name)))
261 switch v {
262 case "1", "true", "yes", "on":
263 return i18n.T("cfg.val.enabled")
264 case "0", "false", "no", "off":
265 return i18n.T("cfg.val.disabled")
266 case "":
267 if d, ok := lookupEnvDefault(name); ok && d.IsBool {
268 label := i18n.T("cfg.val.disabled")
269 if strings.EqualFold(d.Value, "true") {
270 label = i18n.T("cfg.val.enabled")
271 }
272 return defaultMarker + label
273 }
274 return i18n.T("cfg.val.default")
275 default:
276 return v
277 }
278}
279
280// shorten trims long values (paths, tokens) for display.
281func shorten(s string, maxLen int) string {

Callers 12

TestEnvBoolFunction · 0.85
showConfigSchedulerMethod · 0.85
showConfigGeneralMethod · 0.85
showConfigAgentMethod · 0.85
showConfigResilienceMethod · 0.85
showConfigSessionMethod · 0.85
showConfigGraphViewMethod · 0.85
showConfigSecurityMethod · 0.85
showConfigServerMethod · 0.85
showConfigChatMethod · 0.85
showConfigMemoryMethod · 0.85

Calls 2

TFunction · 0.92
lookupEnvDefaultFunction · 0.85

Tested by 1

TestEnvBoolFunction · 0.68