Merge pull request #106172 from pohly/log-kubectl-options-deprecation

kubectl: add deprecation notice to flag usage help
This commit is contained in:
Kubernetes Prow Robot 2021-11-16 07:43:28 -08:00 committed by GitHub
commit 2ee2b8cab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,10 +225,10 @@ func flagsUsages(f *flag.FlagSet) string {
if flag.Hidden { if flag.Hidden {
return return
} }
format := "--%s=%s: %s\n" format := "--%s=%s: %s%s\n"
if flag.Value.Type() == "string" { if flag.Value.Type() == "string" {
format = "--%s='%s': %s\n" format = "--%s='%s': %s%s\n"
} }
if len(flag.Shorthand) > 0 { if len(flag.Shorthand) > 0 {
@ -237,7 +237,12 @@ func flagsUsages(f *flag.FlagSet) string {
format = " %s " + format format = " %s " + format
} }
fmt.Fprintf(x, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage) deprecated := ""
if flag.Deprecated != "" {
deprecated = fmt.Sprintf(" (DEPRECATED: %s)", flag.Deprecated)
}
fmt.Fprintf(x, format, flag.Shorthand, flag.Name, flag.DefValue, flag.Usage, deprecated)
}) })
return x.String() return x.String()