feat: init scaffold

This commit is contained in:
debugtalk
2022-01-08 11:42:39 +08:00
parent 9a31001029
commit e596bddda7
4 changed files with 47 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ import (
// har2caseCmd represents the har2case command
var har2caseCmd = &cobra.Command{
Use: "har2case harPath...",
Use: "har2case $har_path...",
Short: "Convert HAR to json/yaml testcase files",
Long: `Convert HAR to json/yaml testcase files`,
Args: cobra.MinimumNArgs(1),

View File

@@ -10,7 +10,7 @@ import (
// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run path...",
Use: "run $path...",
Short: "run API test",
Long: `run yaml/json testcase files for API test`,
Example: ` $ hrp run demo.json # run specified json testcase file

28
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)
}