Skip to content

docs: refine command usage statements #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func init() {

buildCmd.Flags().StringVarP(&buildDir, "build-dir", "b", "", "dir for build process")

upgradeCmd.Flags().StringVarP(&upgradeVersion, "from", "f", "", "upgrade from specific version, eg: -f v1.1.0")
upgradeCmd.Flags().StringVarP(&upgradeVersion, "from", "f", "", "upgrade to the specific version from your input, eg: -f v1.1.0")

configCmd.Flags().StringSliceVarP(&configFields, "with", "w", []string{}, "the fields that need to be set to the default value, eg: -w allow_password_login")

Expand All @@ -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.",
Expand All @@ -92,11 +91,10 @@ To run answer, use:
- 'answer run' to launch application.`,
}

// runCmd represents the run command
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())
Expand All @@ -105,11 +103,10 @@ To run answer, use:
},
}

// initCmd represents the init command
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)
Expand All @@ -135,11 +132,10 @@ To run answer, use:
},
}

// upgradeCmd represents the upgrade command
upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "upgrade Answer version",
Long: `upgrade Answer version`,
Short: "Upgrade Answer",
Long: `Upgrade Answer to the latest or a specific version`,
Run: func(_ *cobra.Command, _ []string) {
log.SetLogger(log.NewStdLogger(os.Stdout))
cli.FormatAllPath(dataDirPath)
Expand All @@ -157,11 +153,10 @@ To run answer, use:
},
}

// dumpCmd represents the dump command
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)
Expand All @@ -179,10 +174,9 @@ To run answer, use:
},
}

// checkCmd represents the check command
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)
Expand Down Expand Up @@ -214,10 +208,9 @@ To run answer, use:
},
}

// buildCmd used to build another answer with plugins
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"))
Expand All @@ -235,11 +228,10 @@ 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",
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()
Expand All @@ -249,11 +241,10 @@ To run answer, use:
},
}

// configCmd set some config to default value
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)

Expand Down Expand Up @@ -286,10 +277,9 @@ To run answer, use:
},
}

// i18nCmd used to merge i18n files
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 {
Expand Down