refactor: rename command

This commit is contained in:
debugtalk
2021-10-11 15:18:37 +08:00
parent 177106fcad
commit beaf5adaef
7 changed files with 62 additions and 7 deletions

40
httpboomer/cmd/run.go Normal file
View File

@@ -0,0 +1,40 @@
package cmd
import (
"log"
"github.com/spf13/cobra"
"github.com/httprunner/httpboomer"
)
// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run path...",
Short: "run API test",
Long: `run yaml/json testcase files for API test`,
Example: ` $ httpboomer run demo.json # run specified json testcase file
$ httpboomer run demo.yaml # run specified yaml testcase file
$ httpboomer run examples/ # run testcases in specified folder`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// --silent flag
silentFlag, err := cmd.Flags().GetBool("silent")
if err != nil {
return err
}
log.Printf("[runCmd] set --silent flag: %v", silentFlag)
var paths []httpboomer.ITestCase
for _, arg := range args {
paths = append(paths, &httpboomer.TestCasePath{Path: arg})
}
return httpboomer.NewRunner().SetDebug(!silentFlag).Run(paths...)
},
}
func init() {
rootCmd.AddCommand(runCmd)
runCmd.Flags().BoolP("silent", "s", false, "Disable logging request & response details")
// runCmd.Flags().BoolP("gen-html-report", "r", false, "Generate HTML report")
}