You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
432 B
Go
15 lines
432 B
Go
package cobrautil
|
|
|
|
import "github.com/spf13/cobra"
|
|
|
|
// HideInheritedFlags hides inherited flags
|
|
func HideInheritedFlags(cmd *cobra.Command, hidden ...string) {
|
|
for _, h := range hidden {
|
|
// we could use cmd.SetHelpFunc to override the helper
|
|
// but, it's not enough because we also want the generated
|
|
// docs to be updated, so we override the flag instead
|
|
cmd.Flags().String(h, "", "")
|
|
_ = cmd.Flags().MarkHidden(h)
|
|
}
|
|
}
|