refactor: commands

This commit is contained in:
debugtalk
2022-01-08 15:10:37 +08:00
parent d3c97800f0
commit 288346bfd8
18 changed files with 45 additions and 27 deletions

28
cli/hrp/cmd/scaffold.go Normal file
View File

@@ -0,0 +1,28 @@
package cmd
import (
"os"
"github.com/spf13/cobra"
"github.com/httprunner/hrp/internal/builtin"
)
var scaffoldCmd = &cobra.Command{
Use: "startproject $project_name",
Short: "Create a scaffold project",
Args: cobra.ExactValidArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
setLogLevel(logLevel)
},
Run: func(cmd *cobra.Command, args []string) {
err := builtin.CreateScaffold(args[0])
if err != nil {
os.Exit(1)
}
},
}
func init() {
rootCmd.AddCommand(scaffoldCmd)
}