From e218776a4f530ad8ba23d6908006ede26b055360 Mon Sep 17 00:00:00 2001 From: Shaobiao Lin Date: Tue, 6 May 2025 19:06:56 +0800 Subject: [PATCH 1/2] docs(command): remove redundant comments The codes are self-documenting enough. --- cmd/command.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cmd/command.go b/cmd/command.go index fe17713e7..602a12299 100644 --- a/cmd/command.go +++ b/cmd/command.go @@ -82,7 +82,6 @@ func init() { } var ( - // rootCmd represents the base command when called without any subcommands rootCmd = &cobra.Command{ Use: "answer", Short: "Answer is a minimalist open source Q&A community.", @@ -92,7 +91,6 @@ To run answer, use: - 'answer run' to launch application.`, } - // runCmd represents the run command runCmd = &cobra.Command{ Use: "run", Short: "Run the application", @@ -105,7 +103,6 @@ To run answer, use: }, } - // initCmd represents the init command initCmd = &cobra.Command{ Use: "init", Short: "init answer application", @@ -135,7 +132,6 @@ To run answer, use: }, } - // upgradeCmd represents the upgrade command upgradeCmd = &cobra.Command{ Use: "upgrade", Short: "upgrade Answer version", @@ -157,7 +153,6 @@ To run answer, use: }, } - // dumpCmd represents the dump command dumpCmd = &cobra.Command{ Use: "dump", Short: "back up data", @@ -179,7 +174,6 @@ To run answer, use: }, } - // checkCmd represents the check command checkCmd = &cobra.Command{ Use: "check", Short: "checking the required environment", @@ -214,7 +208,6 @@ To run answer, use: }, } - // buildCmd used to build another answer with plugins buildCmd = &cobra.Command{ Use: "build", Short: "used to build answer with plugins", @@ -235,7 +228,6 @@ To run answer, use: }, } - // pluginCmd prints all plugins packed in the binary pluginCmd = &cobra.Command{ Use: "plugin", Short: "prints all plugins packed in the binary", @@ -249,7 +241,6 @@ To run answer, use: }, } - // configCmd set some config to default value configCmd = &cobra.Command{ Use: "config", Short: "set some config to default value", @@ -286,7 +277,6 @@ To run answer, use: }, } - // i18nCmd used to merge i18n files i18nCmd = &cobra.Command{ Use: "i18n", Short: "overwrite i18n files", From 75c5c8931b0c1ae7460917071759a0bb3b3e2dc4 Mon Sep 17 00:00:00 2001 From: Shaobiao Lin Date: Tue, 6 May 2025 19:59:15 +0800 Subject: [PATCH 2/2] docs(command): unify style of usage statements close #1330 --- cmd/command.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/command.go b/cmd/command.go index 602a12299..7d779893f 100644 --- a/cmd/command.go +++ b/cmd/command.go @@ -93,8 +93,8 @@ To run answer, use: runCmd = &cobra.Command{ Use: "run", - Short: "Run the application", - Long: `Run the application`, + Short: "Run Answer", + Long: `Start running Answer`, Run: func(_ *cobra.Command, _ []string) { cli.FormatAllPath(dataDirPath) fmt.Println("config file path: ", cli.GetConfigFilePath()) @@ -105,8 +105,8 @@ To run answer, use: initCmd = &cobra.Command{ Use: "init", - Short: "init answer application", - Long: `init answer application`, + Short: "Initialize Answer", + Long: `Initialize Answer with specified configuration`, Run: func(_ *cobra.Command, _ []string) { // check config file and database. if config file exists and database is already created, init done cli.InstallAllInitialEnvironment(dataDirPath) @@ -134,8 +134,8 @@ To run answer, use: upgradeCmd = &cobra.Command{ Use: "upgrade", - Short: "upgrade Answer version", - Long: `upgrade Answer version`, + Short: "Upgrade Answer", + Long: `Upgrade Answer to the latest version`, Run: func(_ *cobra.Command, _ []string) { log.SetLogger(log.NewStdLogger(os.Stdout)) cli.FormatAllPath(dataDirPath) @@ -155,8 +155,8 @@ To run answer, use: dumpCmd = &cobra.Command{ Use: "dump", - Short: "back up data", - Long: `back up data`, + Short: "Back up data", + Long: `Back up database into an SQL file`, Run: func(_ *cobra.Command, _ []string) { fmt.Println("Answer is backing up data") cli.FormatAllPath(dataDirPath) @@ -176,7 +176,7 @@ To run answer, use: checkCmd = &cobra.Command{ Use: "check", - Short: "checking the required environment", + Short: "Check the required environment", Long: `Check if the current environment meets the startup requirements`, Run: func(_ *cobra.Command, _ []string) { cli.FormatAllPath(dataDirPath) @@ -210,7 +210,7 @@ To run answer, use: buildCmd = &cobra.Command{ Use: "build", - Short: "used to build answer with plugins", + Short: "Build Answer with plugins", Long: `Build a new Answer with plugins that you need`, Run: func(_ *cobra.Command, _ []string) { fmt.Printf("try to build a new answer with plugins:\n%s\n", strings.Join(buildWithPlugins, "\n")) @@ -230,8 +230,8 @@ To run answer, use: pluginCmd = &cobra.Command{ Use: "plugin", - Short: "prints all plugins packed in the binary", - Long: `prints all plugins packed in the binary`, + Short: "Print all plugins packed in the binary", + Long: `Print all plugins packed in the binary`, Run: func(_ *cobra.Command, _ []string) { _ = plugin.CallBase(func(base plugin.Base) error { info := base.Info() @@ -243,8 +243,8 @@ To run answer, use: configCmd = &cobra.Command{ Use: "config", - Short: "set some config to default value", - Long: `set some config to default value`, + Short: "Set some config to default value", + Long: `Set some config to default value`, Run: func(_ *cobra.Command, _ []string) { cli.FormatAllPath(dataDirPath) @@ -279,7 +279,7 @@ To run answer, use: i18nCmd = &cobra.Command{ Use: "i18n", - Short: "overwrite i18n files", + Short: "Overwrite i18n files", Long: `Merge i18n files from plugins to original i18n files. It will overwrite the original i18n files`, Run: func(_ *cobra.Command, _ []string) { if err := cli.ReplaceI18nFilesLocal(i18nTargetPath); err != nil {