Skip to content

Commit

Permalink
fix app list
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Aug 6, 2022
1 parent bdc60b3 commit 8d201a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 47 deletions.
67 changes: 21 additions & 46 deletions cmd/app/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,58 +33,33 @@ var listCmd = &cobra.Command{
Short: "show app list",
Long: "show app list",
RunE: func(cmd *cobra.Command, args []string) error {
usbMuxClient, err := giDevice.NewUsbmux()
if err != nil {
return util.NewErrorPrint(util.ErrConnect, "usbMux", err)
device := util.GetDeviceByUdId(udid)
if device == nil {
os.Exit(0)
}
list, err1 := usbMuxClient.Devices()
if err1 != nil {
return util.NewErrorPrint(util.ErrSendCommand, "listDevices", err1)
result, errList := device.InstallationProxyBrowse(
giDevice.WithApplicationType(giDevice.ApplicationTypeUser),
giDevice.WithReturnAttributes("CFBundleVersion", "CFBundleDisplayName", "CFBundleIdentifier"))
if errList != nil {
return util.NewErrorPrint(util.ErrSendCommand, "appList", errList)
}
if len(list) != 0 {
var device giDevice.Device
if len(udid) != 0 {
for i, d := range list {
if d.Properties().SerialNumber == udid {
device = list[i]
break
}
}
} else {
device = list[0]
}
if device.Properties().SerialNumber != "" {
result, errList := device.InstallationProxyBrowse(
giDevice.WithApplicationType(giDevice.ApplicationTypeUser),
giDevice.WithReturnAttributes("CFBundleVersion", "CFBundleDisplayName", "CFBundleIdentifier"))
if errList != nil {
return util.NewErrorPrint(util.ErrSendCommand, "appList", errList)
}
var appList entity.AppList
for _, app := range result {
a := entity.Application{}
mapstructure.Decode(app, &a)
if a.CFBundleIdentifier != "" && a.CFBundleDisplayName != "" && a.CFBundleVersion != "" {
if showIcon {
icon, errIcon := device.GetIconPNGData(a.CFBundleIdentifier)
if errIcon == nil {
data, _ := ioutil.ReadAll(icon)
a.IconBase64 = base64.StdEncoding.EncodeToString(data)
}
}
appList.ApplicationList = append(appList.ApplicationList, a)
var appList entity.AppList
for _, app := range result {
a := entity.Application{}
mapstructure.Decode(app, &a)
if a.CFBundleIdentifier != "" && a.CFBundleDisplayName != "" && a.CFBundleVersion != "" {
if showIcon {
icon, errIcon := device.GetIconPNGData(a.CFBundleIdentifier)
if errIcon == nil {
data, _ := ioutil.ReadAll(icon)
a.IconBase64 = base64.StdEncoding.EncodeToString(data)
}
}
data := util.ResultData(appList)
fmt.Println(util.Format(data, isFormat, isJson))
} else {
fmt.Println("device no found")
os.Exit(0)
appList.ApplicationList = append(appList.ApplicationList, a)
}
} else {
fmt.Println("no device connected")
os.Exit(0)
}
data := util.ResultData(appList)
fmt.Println(util.Format(data, isFormat, isJson))
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var versionCmd = &cobra.Command{
Short: "Version code of sib",
Long: "Version code of sib",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("1.1.4")
fmt.Println("1.1.5")
},
}

Expand Down

0 comments on commit 8d201a0

Please sign in to comment.