Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credential process support #384

Merged
merged 12 commits into from
Apr 30, 2024
Prev Previous commit
Next Next commit
cleanup code, comment debug statements, remove unused code
bitte-ein-bit committed Mar 8, 2024
commit 038bde882735caae330f65d6fb2d094cacc0675f
16 changes: 1 addition & 15 deletions cmd/get.go
Original file line number Diff line number Diff line change
@@ -53,27 +53,13 @@
)

// Mark the old flag as deprecated.
cmdGet.Flags().MarkDeprecated("write-to-file", "please use output-file instead.")

Check failure on line 56 in cmd/get.go

GitHub Actions / lint

Error return value of `(*github.com/spf13/pflag.FlagSet).MarkDeprecated` is not checked (errcheck)
cmdGet.Flags().MarkDeprecated("shell", "please use output-environment instead.")

Check failure on line 57 in cmd/get.go

GitHub Actions / lint

Error return value of `(*github.com/spf13/pflag.FlagSet).MarkDeprecated` is not checked (errcheck)

// SetNormalize function to translate the use of `old-flag` to `new-flag`
// cmdGet.Flags().SetNormalizeFunc(normalizeFlagName)

// cmdGet.MarkFlagsMutuallyExclusive("output-environment", "output-process")
cmdGet.MarkFlagsMutuallyExclusive("output", "shell", "write-to-file")

}

// func normalizeFlagName(f *pflag.FlagSet, name string) pflag.NormalizedName {
// switch name {
// case "write-to-file":
// name = "output"
// case "shell":
// name = "output"
// writeToFile = "environment"
// }
// return pflag.NormalizedName(name)
// }

func preferredOutput(cmd *cobra.Command, app string) string {
// Order of preference:
// * output flag
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -147,15 +147,15 @@
// Determine the naming convention of the flags when represented in the config file
configName := fmt.Sprintf("global.%s", f.Name)
configName = strings.ReplaceAll(configName, "-", ".")
fmt.Fprintf(os.Stderr, "Checking Flag: %s\n", configName)
//fmt.Fprintf(os.Stderr, "Checking Flag: %s\n", configName)

// Apply the viper config value to the flag when the flag is not set and viper has a value
if !f.Changed && v.IsSet(configName) {
fmt.Fprintf(os.Stderr, "Setting Flag %s by config: %s\n", f.Name, configName)
//fmt.Fprintf(os.Stderr, "Setting Flag %s by config: %s\n", f.Name, configName)
val := v.Get(configName)
cmd.Flags().Set(f.Name, fmt.Sprintf("%v", val))

Check failure on line 156 in cmd/root.go

GitHub Actions / lint

Error return value of `(*github.com/spf13/pflag.FlagSet).Set` is not checked (errcheck)
} else {
fmt.Fprintf(os.Stderr, "Using Flag %s default: %v\n", f.Name, f.DefValue)
/*} else {
fmt.Fprintf(os.Stderr, "Using Flag %s default: %v\n", f.Name, f.DefValue)*/
}
})
}