MCPcopy
hub / github.com/spf13/cobra / getEnvConfig

Function getEnvConfig

completions.go:1014–1020  ·  view source on GitHub ↗

getEnvConfig returns the value of the configuration environment variable <PROGRAM>_<SUFFIX> where <PROGRAM> is the name of the root command in upper case, with all non-ASCII-alphanumeric characters replaced by `_`. If the value is empty or not set, the value of the environment variable COBRA_<SUFFIX

(cmd *Command, suffix string)

Source from the content-addressed store, hash-verified

1012// If the value is empty or not set, the value of the environment variable
1013// COBRA_<SUFFIX> is returned instead.
1014func getEnvConfig(cmd *Command, suffix string) string {
1015 v := os.Getenv(configEnvVar(cmd.Root().Name(), suffix))
1016 if v == "" {
1017 v = os.Getenv(configEnvVar(configEnvVarGlobalPrefix, suffix))
1018 }
1019 return v
1020}

Callers 2

initCompleteCmdMethod · 0.85
TestGetEnvConfigFunction · 0.85

Calls 3

configEnvVarFunction · 0.85
NameMethod · 0.80
RootMethod · 0.80

Tested by 1

TestGetEnvConfigFunction · 0.68