mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
change: go ios apps
This commit is contained in:
+32
-12
@@ -2,12 +2,18 @@ package ios
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
giDevice "github.com/electricbubble/gidevice"
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Application struct {
|
||||||
|
CFBundleVersion string `json:"version"`
|
||||||
|
CFBundleDisplayName string `json:"name"`
|
||||||
|
CFBundleIdentifier string `json:"bundleId"`
|
||||||
|
}
|
||||||
|
|
||||||
var listAppsCmd = &cobra.Command{
|
var listAppsCmd = &cobra.Command{
|
||||||
Use: "apps",
|
Use: "apps",
|
||||||
Short: "List all iOS installed apps",
|
Short: "List all iOS installed apps",
|
||||||
@@ -17,17 +23,31 @@ var listAppsCmd = &cobra.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
apps, err := device.AppList()
|
var applicationType giDevice.ApplicationType
|
||||||
if err != nil {
|
switch appType {
|
||||||
return errors.Wrap(err, "get ios apps failed")
|
case "user":
|
||||||
|
applicationType = giDevice.ApplicationTypeUser
|
||||||
|
case "system":
|
||||||
|
applicationType = giDevice.ApplicationTypeSystem
|
||||||
|
case "internal":
|
||||||
|
applicationType = giDevice.ApplicationTypeInternal
|
||||||
|
case "all":
|
||||||
|
applicationType = giDevice.ApplicationTypeAny
|
||||||
}
|
}
|
||||||
for _, app := range apps {
|
|
||||||
if appType != "all" && strings.ToLower(app.Type) != appType {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("%-10.10s %-30.30s %-50.50s %-s\n",
|
result, errList := device.InstallationProxyBrowse(
|
||||||
app.Type, app.DisplayName, app.CFBundleIdentifier, app.Version)
|
giDevice.WithApplicationType(applicationType),
|
||||||
|
giDevice.WithReturnAttributes("CFBundleVersion", "CFBundleDisplayName", "CFBundleIdentifier"))
|
||||||
|
if errList != nil {
|
||||||
|
return fmt.Errorf("get app list failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, app := range result {
|
||||||
|
a := Application{}
|
||||||
|
mapstructure.Decode(app, &a)
|
||||||
|
|
||||||
|
fmt.Printf("%-30.30s %-50.50s %-s\n",
|
||||||
|
a.CFBundleDisplayName, a.CFBundleIdentifier, a.CFBundleVersion)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -37,6 +57,6 @@ var appType string
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
listAppsCmd.Flags().StringVarP(&udid, "udid", "u", "", "filter by device's udid")
|
listAppsCmd.Flags().StringVarP(&udid, "udid", "u", "", "filter by device's udid")
|
||||||
listAppsCmd.Flags().StringVarP(&appType, "type", "t", "user", "filter application type [user|system|pluginkit|all]")
|
listAppsCmd.Flags().StringVarP(&appType, "type", "t", "user", "filter application type [user|system|internal|all]")
|
||||||
iosRootCmd.AddCommand(listAppsCmd)
|
iosRootCmd.AddCommand(listAppsCmd)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ Copyright 2017 debugtalk`,
|
|||||||
}
|
}
|
||||||
if !logJSON {
|
if !logJSON {
|
||||||
log.Logger = zerolog.New(zerolog.ConsoleWriter{NoColor: noColor, Out: os.Stderr}).With().Timestamp().Logger()
|
log.Logger = zerolog.New(zerolog.ConsoleWriter{NoColor: noColor, Out: os.Stderr}).With().Timestamp().Logger()
|
||||||
log.Info().Msg("Set log to color console other than JSON format.")
|
log.Info().Msg("Set log to color console")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Version: version.VERSION,
|
Version: version.VERSION,
|
||||||
|
|||||||
Reference in New Issue
Block a user