mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-10 17:43:00 +08:00
feat: reboot or shutdown ios device
This commit is contained in:
@@ -3,8 +3,9 @@ package adb
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var androidRootCmd = &cobra.Command{
|
||||
Use: "adb",
|
||||
Short: "simple utils for android device management",
|
||||
Use: "adb",
|
||||
Short: "simple utils for android device management",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
func Init(rootCmd *cobra.Command) {
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
)
|
||||
|
||||
var iosRootCmd = &cobra.Command{
|
||||
Use: "ios",
|
||||
Short: "simple utils for ios device management",
|
||||
Use: "ios",
|
||||
Short: "simple utils for ios device management",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||
}
|
||||
|
||||
func getDevice(udid string) (giDevice.Device, error) {
|
||||
|
||||
37
hrp/cmd/ios/reboot.go
Normal file
37
hrp/cmd/ios/reboot.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package ios
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rebootCmd = &cobra.Command{
|
||||
Use: "reboot",
|
||||
Short: "reboot or shutdown ios device",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
device, err := getDevice(udid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if isShutdown {
|
||||
err = device.Shutdown()
|
||||
} else {
|
||||
err = device.Reboot()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("reboot %s success\n", device.Properties().UDID)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var isShutdown bool
|
||||
|
||||
func init() {
|
||||
rebootCmd.Flags().StringVarP(&udid, "udid", "u", "", "filter by device's udid")
|
||||
rebootCmd.Flags().BoolVarP(&isShutdown, "shutdown", "s", false, "shutdown ios device")
|
||||
iosRootCmd.AddCommand(rebootCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user