feat(goctl): Support gateway sample generation (#3049)
This commit is contained in:
36
tools/goctl/env/cmd.go
vendored
36
tools/goctl/env/cmd.go
vendored
@@ -1,6 +1,6 @@
|
||||
package env
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import "github.com/zeromicro/go-zero/tools/goctl/internal/cobrax"
|
||||
|
||||
var (
|
||||
sliceVarWriteValue []string
|
||||
@@ -9,38 +9,20 @@ var (
|
||||
boolVarInstall bool
|
||||
|
||||
// Cmd describes an env command.
|
||||
Cmd = &cobra.Command{
|
||||
Use: "env",
|
||||
Short: "Check or edit goctl environment",
|
||||
RunE: write,
|
||||
}
|
||||
installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "Goctl env installation",
|
||||
RunE: install,
|
||||
}
|
||||
checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Detect goctl env and dependency tools",
|
||||
RunE: check,
|
||||
}
|
||||
Cmd = cobrax.NewCommand("env", cobrax.WithRunE(write))
|
||||
installCmd = cobrax.NewCommand("install", cobrax.WithRunE(install))
|
||||
checkCmd = cobrax.NewCommand("check", cobrax.WithRunE(check))
|
||||
)
|
||||
|
||||
func init() {
|
||||
// The root command flags
|
||||
Cmd.Flags().StringSliceVarP(&sliceVarWriteValue,
|
||||
"write", "w", nil, "Edit goctl environment")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarForce,
|
||||
"force", "f", false,
|
||||
"Silent installation of non-existent dependencies")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarVerbose,
|
||||
"verbose", "v", false, "Enable log output")
|
||||
Cmd.Flags().StringSliceVarP(&sliceVarWriteValue, "write", "w")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarForce, "force", "f")
|
||||
Cmd.PersistentFlags().BoolVarP(&boolVarVerbose, "verbose", "v")
|
||||
|
||||
// The sub-command flags
|
||||
checkCmd.Flags().BoolVarP(&boolVarInstall, "install", "i",
|
||||
false, "Install dependencies if not found")
|
||||
checkCmd.Flags().BoolVarP(&boolVarInstall, "install", "i")
|
||||
|
||||
// Add sub-command
|
||||
Cmd.AddCommand(installCmd)
|
||||
Cmd.AddCommand(checkCmd)
|
||||
Cmd.AddCommand(checkCmd, installCmd)
|
||||
}
|
||||
|
||||
4
tools/goctl/env/env.go
vendored
4
tools/goctl/env/env.go
vendored
@@ -7,10 +7,10 @@ import (
|
||||
"github.com/zeromicro/go-zero/tools/goctl/pkg/env"
|
||||
)
|
||||
|
||||
func write(_ *cobra.Command, _ []string) error {
|
||||
func write(_ *cobra.Command, args []string) error {
|
||||
if len(sliceVarWriteValue) > 0 {
|
||||
return env.WriteEnv(sliceVarWriteValue)
|
||||
}
|
||||
fmt.Println(env.Print())
|
||||
fmt.Println(env.Print(args...))
|
||||
return nil
|
||||
}
|
||||
|
||||
4
tools/goctl/env/install.go
vendored
4
tools/goctl/env/install.go
vendored
@@ -1,8 +1,6 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func install(_ *cobra.Command, _ []string) error {
|
||||
return Prepare(true, boolVarForce, boolVarVerbose)
|
||||
|
||||
Reference in New Issue
Block a user