From e596bddda74facbd1a660f3417cd336484dbce15 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Sat, 8 Jan 2022 11:42:39 +0800 Subject: [PATCH] feat: init scaffold --- hrp/cmd/har2case.go | 2 +- hrp/cmd/run.go | 2 +- hrp/cmd/scaffold.go | 28 ++++++++++++++++++++++++++++ internal/builtin/scaffold.go | 17 +++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 hrp/cmd/scaffold.go create mode 100644 internal/builtin/scaffold.go diff --git a/hrp/cmd/har2case.go b/hrp/cmd/har2case.go index 7512f241..4269dbee 100644 --- a/hrp/cmd/har2case.go +++ b/hrp/cmd/har2case.go @@ -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), diff --git a/hrp/cmd/run.go b/hrp/cmd/run.go index 29aa2486..274c7424 100644 --- a/hrp/cmd/run.go +++ b/hrp/cmd/run.go @@ -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 diff --git a/hrp/cmd/scaffold.go b/hrp/cmd/scaffold.go new file mode 100644 index 00000000..2e2fed45 --- /dev/null +++ b/hrp/cmd/scaffold.go @@ -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) +} diff --git a/internal/builtin/scaffold.go b/internal/builtin/scaffold.go new file mode 100644 index 00000000..0a57f2aa --- /dev/null +++ b/internal/builtin/scaffold.go @@ -0,0 +1,17 @@ +package builtin + +import ( + "fmt" + + "github.com/httprunner/hrp/internal/ga" +) + +func CreateScaffold(projectName string) error { + // report event + ga.SendEvent(ga.EventTracking{ + Category: "Scaffold", + Action: "hrp startproject", + }) + + return fmt.Errorf("not implemented") +}