From 472bd6fba709b5fab74c1783f091f8468cabaefe Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Wed, 6 Nov 2024 00:30:08 +0800 Subject: [PATCH] fix(cli): correct help text --- src/cli/disable.go | 5 ++--- src/cli/enable.go | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cli/disable.go b/src/cli/disable.go index ff03ca8e..fafd1ce6 100644 --- a/src/cli/disable.go +++ b/src/cli/disable.go @@ -2,16 +2,15 @@ package cli import ( "fmt" - "strings" "github.com/spf13/cobra" ) // getCmd represents the get command var disableCmd = &cobra.Command{ - Use: fmt.Sprintf(toggleUse, "disable", strings.Join(toggleArgs, "|")), + Use: fmt.Sprintf(toggleUse, "disable"), Short: "Disable a feature", - Long: fmt.Sprintf(toggleLong, "Disable", "disable"), + Long: fmt.Sprintf(toggleLong, "Disable"), ValidArgs: toggleArgs, Args: NoArgsOrOneValidArg, Run: func(cmd *cobra.Command, args []string) { diff --git a/src/cli/enable.go b/src/cli/enable.go index 208abeb8..3c481577 100644 --- a/src/cli/enable.go +++ b/src/cli/enable.go @@ -12,23 +12,21 @@ import ( ) var ( - toggleUse = "%s [%s]" - toggleLong = `%s a feature - -This command is used to %s one of the following features: - -- upgradenotice` + toggleHelpText = `%s one of the following features: +` toggleArgs = []string{ config.UPGRADENOTICE, config.AUTOUPGRADE, } + toggleUse = fmt.Sprintf("%%s [%s]", strings.Join(toggleArgs, "|")) + toggleLong = strings.Join(append([]string{toggleHelpText}, toggleArgs...), "\n- ") ) // getCmd represents the get command var enableCmd = &cobra.Command{ - Use: fmt.Sprintf(toggleUse, "enable", strings.Join(toggleArgs, "|")), + Use: fmt.Sprintf(toggleUse, "enable"), Short: "Enable a feature", - Long: fmt.Sprintf(toggleLong, "Enable", "enable"), + Long: fmt.Sprintf(toggleLong, "Enable"), ValidArgs: toggleArgs, Args: NoArgsOrOneValidArg, Run: func(cmd *cobra.Command, args []string) {