From 09fdaa8c3557344304ebf8d04cdeb0d02231d787 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 11 Oct 2021 15:33:15 +0800 Subject: [PATCH] feat: gen markdown docs for command --- docs/cmd/httpboomer.md | 25 +++++++++++++++++++++ docs/cmd/httpboomer_boom.md | 40 +++++++++++++++++++++++++++++++++ docs/cmd/httpboomer_har2case.md | 23 +++++++++++++++++++ docs/cmd/httpboomer_run.md | 32 ++++++++++++++++++++++++++ docs/doc_test.go | 18 +++++++++++++++ go.sum | 3 +++ httpboomer/cmd/boom.go | 2 +- httpboomer/cmd/gen_doc.go | 15 ------------- httpboomer/cmd/har2case.go | 2 +- httpboomer/cmd/root.go | 6 ++--- httpboomer/cmd/run.go | 2 +- 11 files changed, 147 insertions(+), 21 deletions(-) create mode 100644 docs/cmd/httpboomer.md create mode 100644 docs/cmd/httpboomer_boom.md create mode 100644 docs/cmd/httpboomer_har2case.md create mode 100644 docs/cmd/httpboomer_run.md create mode 100644 docs/doc_test.go delete mode 100644 httpboomer/cmd/gen_doc.go diff --git a/docs/cmd/httpboomer.md b/docs/cmd/httpboomer.md new file mode 100644 index 00000000..9db2bdf1 --- /dev/null +++ b/docs/cmd/httpboomer.md @@ -0,0 +1,25 @@ +## httpboomer + +One-stop solution for HTTP(S) testing. + +### Synopsis + +HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ + +License: Apache-2.0 +Github: https://github.com/httprunner/httpboomer +Copyright 2021 debugtalk + +### Options + +``` + -h, --help help for httpboomer +``` + +### SEE ALSO + +* [httpboomer boom](httpboomer_boom.md) - run load test with boomer +* [httpboomer har2case](httpboomer_har2case.md) - Convert HAR to json/yaml testcase files +* [httpboomer run](httpboomer_run.md) - run API test + +###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/cmd/httpboomer_boom.md b/docs/cmd/httpboomer_boom.md new file mode 100644 index 00000000..975f13ad --- /dev/null +++ b/docs/cmd/httpboomer_boom.md @@ -0,0 +1,40 @@ +## httpboomer boom + +run load test with boomer + +### Synopsis + +run yaml/json testcase files for load test + +``` +httpboomer boom [flags] +``` + +### Examples + +``` + $ httpboomer boom demo.json # run specified json testcase file + $ httpboomer boom demo.yaml # run specified yaml testcase file + $ httpboomer boom examples/ # run testcases in specified folder +``` + +### Options + +``` + --cpu-profile string Enable CPU profiling. + --cpu-profile-duration duration CPU profile duration. (default 30s) + -h, --help help for boom + --master-host string Host or IP address of locust master for distributed load testing. (default "127.0.0.1") + --master-port int The port to connect to that is used by the locust master for distributed load testing. (default 5557) + --max-rps int Max RPS that boomer can generate, disabled by default. + --mem-profile string Enable memory profiling. + --mem-profile-duration duration Memory profile duration. (default 30s) + --request-increase-rate string Request increase rate, disabled by default. (default "-1") + --run-tasks string Run tasks without connecting to the master, multiply tasks is separated by comma. Usually, it's for debug purpose. +``` + +### SEE ALSO + +* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. + +###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/cmd/httpboomer_har2case.md b/docs/cmd/httpboomer_har2case.md new file mode 100644 index 00000000..d1d82222 --- /dev/null +++ b/docs/cmd/httpboomer_har2case.md @@ -0,0 +1,23 @@ +## httpboomer har2case + +Convert HAR to json/yaml testcase files + +### Synopsis + +Convert HAR to json/yaml testcase files + +``` +httpboomer har2case path... [flags] +``` + +### Options + +``` + -h, --help help for har2case +``` + +### SEE ALSO + +* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. + +###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/cmd/httpboomer_run.md b/docs/cmd/httpboomer_run.md new file mode 100644 index 00000000..6a5a0ef0 --- /dev/null +++ b/docs/cmd/httpboomer_run.md @@ -0,0 +1,32 @@ +## httpboomer run + +run API test + +### Synopsis + +run yaml/json testcase files for API test + +``` +httpboomer run path... [flags] +``` + +### Examples + +``` + $ 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 +``` + +### Options + +``` + -h, --help help for run + -s, --silent Disable logging request & response details +``` + +### SEE ALSO + +* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. + +###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/doc_test.go b/docs/doc_test.go new file mode 100644 index 00000000..ada217a1 --- /dev/null +++ b/docs/doc_test.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "log" + "testing" + + "github.com/spf13/cobra/doc" + + "github.com/httprunner/httpboomer/httpboomer/cmd" +) + +// run this test to generate markdown docs +func TestGenMarkdownTree(t *testing.T) { + err := doc.GenMarkdownTree(cmd.RootCmd, "./cmd/") + if err != nil { + log.Fatal(err) + } +} diff --git a/go.sum b/go.sum index 3fd50847..990fc21b 100644 --- a/go.sum +++ b/go.sum @@ -59,6 +59,7 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -220,11 +221,13 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shirou/gopsutil v3.21.8+incompatible h1:sh0foI8tMRlCidUJR+KzqWYWxrkuuPIGiO6Vp+KXdCU= github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= diff --git a/httpboomer/cmd/boom.go b/httpboomer/cmd/boom.go index 8803dd1f..b8973eb3 100644 --- a/httpboomer/cmd/boom.go +++ b/httpboomer/cmd/boom.go @@ -40,7 +40,7 @@ var cpuProfile string var cpuProfileDuration time.Duration func init() { - rootCmd.AddCommand(boomCmd) + RootCmd.AddCommand(boomCmd) boomCmd.Flags().Int64Var(&maxRPS, "max-rps", 0, "Max RPS that boomer can generate, disabled by default.") boomCmd.Flags().StringVar(&requestIncreaseRate, "request-increase-rate", "-1", "Request increase rate, disabled by default.") diff --git a/httpboomer/cmd/gen_doc.go b/httpboomer/cmd/gen_doc.go deleted file mode 100644 index 32ff7ca0..00000000 --- a/httpboomer/cmd/gen_doc.go +++ /dev/null @@ -1,15 +0,0 @@ -package cmd - -// import ( -// "log" - -// "github.com/spf13/cobra/doc" -// ) - -// func main() { - -// err := doc.GenMarkdownTree(rootCmd, "/tmp") -// if err != nil { -// log.Fatal(err) -// } -// } diff --git a/httpboomer/cmd/har2case.go b/httpboomer/cmd/har2case.go index 72c70e82..7492c63c 100644 --- a/httpboomer/cmd/har2case.go +++ b/httpboomer/cmd/har2case.go @@ -26,7 +26,7 @@ var har2caseCmd = &cobra.Command{ } func init() { - rootCmd.AddCommand(har2caseCmd) + RootCmd.AddCommand(har2caseCmd) // Here you will define your flags and configuration settings. diff --git a/httpboomer/cmd/root.go b/httpboomer/cmd/root.go index f83813f7..ceeb7d06 100644 --- a/httpboomer/cmd/root.go +++ b/httpboomer/cmd/root.go @@ -9,8 +9,8 @@ import ( "github.com/httprunner/httpboomer" ) -// rootCmd represents the base command when called without any subcommands -var rootCmd = &cobra.Command{ +// RootCmd represents the base command when called without any subcommands +var RootCmd = &cobra.Command{ Use: "httpboomer", Short: "One-stop solution for HTTP(S) testing.", Long: `HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ @@ -24,7 +24,7 @@ Copyright 2021 debugtalk`, // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - if err := rootCmd.Execute(); err != nil { + if err := RootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } diff --git a/httpboomer/cmd/run.go b/httpboomer/cmd/run.go index 12b4cd29..a60c80cc 100644 --- a/httpboomer/cmd/run.go +++ b/httpboomer/cmd/run.go @@ -34,7 +34,7 @@ var runCmd = &cobra.Command{ } func init() { - rootCmd.AddCommand(runCmd) + 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") }