summaryrefslogtreecommitdiff
path: root/internal/commands/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/commands/util.go')
-rw-r--r--internal/commands/util.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/internal/commands/util.go b/internal/commands/util.go
index 643105aad..8d8ce06a3 100644
--- a/internal/commands/util.go
+++ b/internal/commands/util.go
@@ -328,18 +328,28 @@ func newHelpTopic(topic, short, body string) (cmd *cobra.Command) {
Short: short,
}
- cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
- _ = cmd.Parent().Help()
+ cmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
+ cmdHelpTopic(cmd, body, topic)
+
+ return nil
+ })
- fmt.Println()
- fmt.Printf("Help Topic: %s\n\n", topic)
- fmt.Print(body)
- fmt.Print("\n\n")
+ cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
+ cmdHelpTopic(cmd, body, topic)
})
return cmd
}
+func cmdHelpTopic(cmd *cobra.Command, body, topic string) {
+ _ = cmd.Parent().Help()
+
+ fmt.Println()
+ fmt.Printf("Help Topic: %s\n\n", topic)
+ fmt.Print(body)
+ fmt.Print("\n\n")
+}
+
func exportYAMLWithJSONSchema(name, filename string, v any) (err error) {
var f *os.File