refactor: rename command

This commit is contained in:
debugtalk
2021-10-11 15:18:37 +08:00
parent 292752c532
commit 939652fb50
7 changed files with 62 additions and 7 deletions

View File

@@ -1,7 +0,0 @@
package main
import "github.com/httprunner/httpboomer/cmd"
func main() {
cmd.Execute()
}

15
httpboomer/cmd/gen_doc.go Normal file
View File

@@ -0,0 +1,15 @@
package cmd
// import (
// "log"
// "github.com/spf13/cobra/doc"
// )
// func main() {
// err := doc.GenMarkdownTree(rootCmd, "/tmp")
// if err != nil {
// log.Fatal(err)
// }
// }

View File

@@ -0,0 +1,40 @@
package cmd
import (
"fmt"
"log"
"github.com/spf13/cobra"
"github.com/httprunner/httpboomer/har2case"
)
// har2caseCmd represents the har2case command
var har2caseCmd = &cobra.Command{
Use: "har2case path...",
Short: "Convert HAR to json/yaml testcase files",
Long: `Convert HAR to json/yaml testcase files`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("har2case called")
var outputFiles []string
for _, arg := range args {
jsonPath, _ := har2case.NewHAR(arg).GenJSON()
outputFiles = append(outputFiles, jsonPath)
}
log.Printf("%v", outputFiles)
},
}
func init() {
rootCmd.AddCommand(har2caseCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// har2caseCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// har2caseCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}

7
httpboomer/main.go Normal file
View File

@@ -0,0 +1,7 @@
package main
import "github.com/httprunner/httpboomer/httpboomer/cmd"
func main() {
cmd.Execute()
}