-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy patharrest.go
61 lines (51 loc) · 1.16 KB
/
arrest.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"iconsole/services"
"path"
"github.com/urfave/cli"
)
func arrestAction(ctx *cli.Context) error {
udid := ctx.String("UDID")
device, err := getDevice(udid)
if err != nil {
return err
}
args := ctx.Args()
if len(args) <= 0 {
return cli.ShowSubcommandHelp(ctx)
}
a, err := services.NewHouseArrestService(device)
if err != nil {
return err
}
afc, err := a.Documents(args[0])
if err != nil {
return err
}
base := "Documents"
if p, err := afc.ReadDirectory(base); err != nil {
return err
} else {
for _, v := range p {
if v != "." && v != ".." {
if i, err := afc.GetFileInfo(path.Join(base, v)); err != nil {
return err
} else if i.IsDir() {
fmt.Printf("%7s %s \x1B[1;34m%s\x1B[0m\n", byteCountDecimal(i.Size()), i.ModTime().Format("2006-01-02 15:04:05"), i.Name())
} else {
fmt.Printf("%7s %s %s\n", byteCountDecimal(i.Size()), i.ModTime().Format("2006-01-02 15:04:05"), i.Name())
}
}
}
}
return nil
}
func initArrest() cli.Command {
return cli.Command{
Name: "arrest",
Usage: "House arrest",
UsageText: "iconsole arrest <BundleID>",
Action: arrestAction,
}
}