Add a util helper for marking a CLI flag as hidden.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2020-10-19 10:48:10 -05:00
parent 3e39800005
commit 4ef41f969d
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D

View File

@ -13,3 +13,12 @@ func mustMarkRequired(cmd *cobra.Command, flags ...string) {
}
}
}
// mustMarkHidden marks the given flags as hidden on the provided cobra.Command. If any of the names are wrong, it panics.
func mustMarkHidden(cmd *cobra.Command, flags ...string) {
for _, flag := range flags {
if err := cmd.Flags().MarkHidden(flag); err != nil {
panic(err)
}
}
}