summaryrefslogtreecommitdiff
path: root/internal/commands/util.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2024-04-11 17:31:16 +1000
committerGitHub <noreply@github.com>2024-04-11 17:31:16 +1000
commitab0d501cabe086d73bb2218ba3dd6606bd6ef12c (patch)
tree5272518161c6180f6a6e46a884e68a0b2e48d66e /internal/commands/util.go
parentaabc8f17a2d7b71bf1f73c22a49188098f2ec757 (diff)
fix(commands): missing hash-password help topic (#7136)
The hash-password command was removed due to a number of issues related to the original implementation which lead to quite a lot of confusion, however we should have introduced a help topic to help users finding the correct command which was not done. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
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