Make getEnvConfig private

This commit is contained in:
Ville Skyttä 2023-12-11 17:37:09 +02:00
parent 97b70019e9
commit 7aa559d693
2 changed files with 4 additions and 4 deletions

View file

@ -212,7 +212,7 @@ func (c *Command) initCompleteCmd(args []string) {
// 2- Even without completions, we need to print the directive
}
noDescriptions := cmd.CalledAs() == ShellCompNoDescRequestCmd || GetEnvConfig(cmd, configEnvVarSuffixDescriptions) == configEnvVarDescriptionsOff
noDescriptions := cmd.CalledAs() == ShellCompNoDescRequestCmd || getEnvConfig(cmd, configEnvVarSuffixDescriptions) == configEnvVarDescriptionsOff
noActiveHelp := GetActiveHelpConfig(finalCmd) == activeHelpGlobalDisable
out := finalCmd.OutOrStdout()
for _, comp := range completions {
@ -920,12 +920,12 @@ func configEnvVar(name, suffix string) string {
return v
}
// GetEnvConfig returns the value of the configuration environment variable
// 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> is returned instead.
func GetEnvConfig(cmd *Command, suffix string) string {
func getEnvConfig(cmd *Command, suffix string) string {
v := os.Getenv(configEnvVar(cmd.Root().Name(), suffix))
if v == "" {
v = os.Getenv(configEnvVar(configEnvVarGlobalPrefix, suffix))

View file

@ -3586,7 +3586,7 @@ func TestGetEnvConfig(t *testing.T) {
defer assertNoErr(t, os.Unsetenv(tc.globalVar))
assertNoErr(t, err)
cmd := &Command{Use: tc.use}
got := GetEnvConfig(cmd, tc.suffix)
got := getEnvConfig(cmd, tc.suffix)
if got != tc.expected {
t.Errorf("expected: %q, got: %q", tc.expected, got)
}