feat: gen markdown docs for command

This commit is contained in:
debugtalk
2021-10-11 15:33:15 +08:00
parent 939652fb50
commit 69e01373d3
11 changed files with 147 additions and 21 deletions

25
docs/cmd/httpboomer.md Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

18
docs/doc_test.go Normal file
View File

@@ -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)
}
}

3
go.sum
View File

@@ -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=

View File

@@ -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.")

View File

@@ -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)
// }
// }

View File

@@ -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.

View File

@@ -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)
}

View File

@@ -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")
}