Skip to content

Commit

Permalink
Skip to print the unused flags in the usage.
Browse files Browse the repository at this point in the history
Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji committed Aug 22, 2024
1 parent a54ae8d commit eaaba57
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions k8s/cmd/commands/util/usage/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ func CobraUsage(cmd *cobra.Command) (Command, error) {
c.Children = append(c.Children, childUsage)
}
cmd.LocalFlags().VisitAll(func(flag *pflag.Flag) {
c.Flags = append(c.Flags, FlagUsage(flag))
if flag.Name != "log-flush-frequency" {
c.Flags = append(c.Flags, FlagUsage(flag))
}
})
cmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
c.GlobalFlags = append(c.GlobalFlags, FlagUsage(flag))
if flag.Name != "log-flush-frequency" {
c.GlobalFlags = append(c.GlobalFlags, FlagUsage(flag))
}
})
return c, nil
}

0 comments on commit eaaba57

Please sign in to comment.