-
Notifications
You must be signed in to change notification settings - Fork 32
/
reboot.go
38 lines (32 loc) · 802 Bytes
/
reboot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ios
import (
"fmt"
"github.com/spf13/cobra"
)
var rebootCmd = &cobra.Command{
Use: "reboot",
Short: "reboot or shutdown ios device",
PersistentPreRun: func(cmd *cobra.Command, args []string) {},
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", "", "specify device by udid")
rebootCmd.Flags().BoolVarP(&isShutdown, "shutdown", "s", false, "shutdown ios device")
iosRootCmd.AddCommand(rebootCmd)
}