change: make API more concise

This commit is contained in:
debugtalk
2021-12-07 21:16:32 +08:00
parent 1a36547ff0
commit bd3aae18f6
15 changed files with 154 additions and 137 deletions

View File

@@ -19,7 +19,7 @@ var boomCmd = &cobra.Command{
$ hrp boom examples/ # run testcases in specified folder`,
Args: cobra.MinimumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
hrp.SetLogLevel("WARN") // disable info logs for load testing
hrp.SetLogger("WARN", logJSON) // disable info logs for load testing
},
Run: func(cmd *cobra.Command, args []string) {
var paths []hrp.ITestCase

View File

@@ -1,9 +1,9 @@
package cmd
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/httprunner/hrp"
"github.com/httprunner/hrp/har2case"
)
@@ -37,6 +37,7 @@ var har2caseCmd = &cobra.Command{
}
outputFiles = append(outputFiles, outputPath)
}
log := hrp.GetLogger()
log.Info().Strs("output", outputFiles).Msg("convert testcase success")
return nil
},

View File

@@ -14,16 +14,13 @@ import (
var RootCmd = &cobra.Command{
Use: "hrp",
Short: "One-stop solution for HTTP(S) testing.",
Long: `hrp (HttpRunner+) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨
Long: `hrp (HttpRunner+) is the one-stop solution for HTTP(S) testing. Enjoy! ✨ 🚀 ✨
License: Apache-2.0
Github: https://github.com/httprunner/hrp
Copyright 2021 debugtalk`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if !logJSON {
hrp.SetLogPretty()
}
hrp.SetLogLevel(logLevel)
hrp.SetLogger(logLevel, logJSON)
},
Version: version.VERSION,
}