mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 00:39:34 +08:00
feat: reboot or shutdown ios device
This commit is contained in:
@@ -3,8 +3,9 @@ package adb
|
|||||||
import "github.com/spf13/cobra"
|
import "github.com/spf13/cobra"
|
||||||
|
|
||||||
var androidRootCmd = &cobra.Command{
|
var androidRootCmd = &cobra.Command{
|
||||||
Use: "adb",
|
Use: "adb",
|
||||||
Short: "simple utils for android device management",
|
Short: "simple utils for android device management",
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(rootCmd *cobra.Command) {
|
func Init(rootCmd *cobra.Command) {
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var iosRootCmd = &cobra.Command{
|
var iosRootCmd = &cobra.Command{
|
||||||
Use: "ios",
|
Use: "ios",
|
||||||
Short: "simple utils for ios device management",
|
Short: "simple utils for ios device management",
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDevice(udid string) (giDevice.Device, error) {
|
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