Skip to content

Commit

Permalink
Make getEnvConfig private
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Dec 11, 2023
1 parent 97b7001 commit 7aa559d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7aa559d

Please sign in to comment.