mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-27 19:30:20 +08:00
feat: support ping command
This commit is contained in:
31
hrp/cmd/dial.go
Normal file
31
hrp/cmd/dial.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/dial"
|
||||
)
|
||||
|
||||
var pingOptions dial.PingOptions
|
||||
|
||||
var pingCmd = &cobra.Command{
|
||||
Use: "ping $url",
|
||||
Short: "run integrated ping command",
|
||||
Args: cobra.ExactArgs(1),
|
||||
PreRun: func(cmd *cobra.Command, args []string) {
|
||||
setLogLevel(logLevel)
|
||||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return dial.DoPing(&pingOptions, args)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(pingCmd)
|
||||
pingCmd.Flags().IntVarP(&pingOptions.Count, "count", "c", 10, "Stop after sending (and receiving) N packets")
|
||||
pingCmd.Flags().DurationVarP(&pingOptions.Timeout, "timeout", "t", 20*time.Second, "Ping exits after N seconds")
|
||||
pingCmd.Flags().DurationVarP(&pingOptions.Interval, "interval", "i", 1*time.Second, "Wait N seconds between sending each packet")
|
||||
pingCmd.Flags().BoolVar(&pingOptions.SaveTests, "save-tests", false, "Save ping results json")
|
||||
}
|
||||
Reference in New Issue
Block a user