Skip to content

Commit

Permalink
app调整
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Jul 24, 2022
1 parent 66205fe commit d1fe924
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 23 deletions.
7 changes: 3 additions & 4 deletions cmd/afc/afcInit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import (

var afcRootCMD *cobra.Command

var udid string
var bundleID string
var udid, bundleId string

// InitAfc 用于初始化,在上层中调用这个方法,否则不会正常进行初始化
func InitAfc(afcCMD *cobra.Command) {
Expand All @@ -53,14 +52,14 @@ func getAFCServer() (afcServer giDevice.Afc) {
os.Exit(0)
}
var err error
if bundleID != "" {
if bundleId != "" {
var houseArrestSrv giDevice.HouseArrest
houseArrestSrv, err = device.HouseArrestService()
if err != nil {
fmt.Println(err)
os.Exit(0)
}
afcServer, err = houseArrestSrv.Documents(bundleID)
afcServer, err = houseArrestSrv.Documents(bundleId)
} else {
afcServer, err = device.AfcService()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var catFilePath string
func initCat() {
afcRootCMD.AddCommand(afcCatCmd)
afcCatCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcCatCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcCatCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcCatCmd.Flags().StringVarP(&catFilePath, "file", "f", "", "cat file path")
afcCatCmd.MarkFlagRequired("file")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var lsDirPath string
func initLs() {
afcRootCMD.AddCommand(afcLsCmd)
afcLsCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcLsCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcLsCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcLsCmd.Flags().StringVarP(&lsDirPath, "folder", "f", "", "ls folder path")
afcLsCmd.MarkFlagRequired("folder")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var mkDir string
func initMkDir() {
afcRootCMD.AddCommand(afcMkDirCmd)
afcMkDirCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcMkDirCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcMkDirCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcMkDirCmd.Flags().StringVarP(&mkDir, "folder", "f", "", "mkdir directory path")
afcMkDirCmd.MarkFlagRequired("folder")
}
2 changes: 1 addition & 1 deletion cmd/afc/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var pullSaveLocalPath string
func initPullCmd() {
afcRootCMD.AddCommand(afcPullCmd)
afcPullCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcPullCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcPullCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcPullCmd.Flags().StringVarP(&pullDevicePath, "devicePath", "d", "", "pull file or directory device path")
afcPullCmd.Flags().StringVarP(&pullSaveLocalPath, "localPath", "l", "", "pull save file or directory to local path")
afcPullCmd.MarkFlagRequired("devicePath")
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var pushSaveDevicePath string
func initPush() {
afcRootCMD.AddCommand(afcPushCmd)
afcPushCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcPushCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcPushCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcPushCmd.Flags().StringVarP(&pushLocalPath, "localPath", "l", "", "push file or directory local path")
afcPushCmd.Flags().StringVarP(&pushSaveDevicePath, "devicePath", "d", "", "push save file or directory to device path")
afcPushCmd.MarkFlagRequired("localPath")
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var rmFilePath string
func initRM() {
afcRootCMD.AddCommand(afcRMCmd)
afcRMCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcRMCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcRMCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcRMCmd.Flags().StringVarP(&rmFilePath, "file", "f", "", "the address of the file to be deleted")
afcRMCmd.MarkFlagRequired("file")
}
2 changes: 1 addition & 1 deletion cmd/afc/rmtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var rmDir string
func initRMTree() {
afcRootCMD.AddCommand(afcRMTreeCmd)
afcRMTreeCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcRMTreeCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcRMTreeCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcRMTreeCmd.Flags().StringVarP(&rmDir, "folder", "f", "", "folder address to delete")
afcRMTreeCmd.MarkFlagRequired("folder")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/afc/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var statPath string
func initStat() {
afcRootCMD.AddCommand(afcStatCmd)
afcStatCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcStatCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcStatCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcStatCmd.Flags().StringVarP(&statPath, "path", "p", "", "files or folders for which details need to be viewed")
afcStatCmd.MarkFlagRequired("path")
}
2 changes: 1 addition & 1 deletion cmd/afc/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var treeDir string
func initTree() {
afcRootCMD.AddCommand(afcTreeCmd)
afcTreeCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber ( default first device )")
afcTreeCmd.Flags().StringVarP(&bundleID, "bundleId", "b", "", "app bundleId")
afcTreeCmd.Flags().StringVarP(&bundleId, "bundleId", "b", "", "app bundleId")
afcTreeCmd.Flags().StringVarP(&treeDir, "folder", "f", "", "folder path to tree view")
afcTreeCmd.MarkFlagRequired("folder")
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package cmd

import (
"github.com/SonicCloudOrg/sonic-ios-bridge/cmd/app"
"github.com/spf13/cobra"
)

Expand All @@ -31,4 +32,5 @@ var appCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(appCmd)
app.InitApp(appCmd)
}
31 changes: 31 additions & 0 deletions cmd/app/appInit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) [SonicCloudOrg] Sonic Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package app

import "github.com/spf13/cobra"

var appRootCMD *cobra.Command

var udid, bundleId string
var isJson, isDetail, isFormat bool

func InitApp(appCMD *cobra.Command) {
appRootCMD = appCMD

initAppInstall()
initAppList()
}
6 changes: 3 additions & 3 deletions cmd/install.go → cmd/app/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
package cmd
package app

import (
"fmt"
Expand Down Expand Up @@ -44,8 +44,8 @@ var installCmd = &cobra.Command{

var path string

func init() {
appCmd.AddCommand(installCmd)
func initAppInstall() {
appRootCMD.AddCommand(installCmd)
installCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber")
installCmd.Flags().StringVarP(&path, "path", "p", "", "path of ipa file")
installCmd.MarkFlagRequired("path")
Expand Down
6 changes: 3 additions & 3 deletions cmd/list.go → cmd/app/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
package cmd
package app

import (
"encoding/base64"
Expand Down Expand Up @@ -91,8 +91,8 @@ var listCmd = &cobra.Command{

var showIcon bool

func init() {
appCmd.AddCommand(listCmd)
func initAppList() {
appRootCMD.AddCommand(listCmd)
listCmd.Flags().BoolVarP(&showIcon, "icon", "i", false, "show app icon")
listCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber")
listCmd.Flags().BoolVarP(&isJson, "json", "j", false, "convert to JSON string")
Expand Down
9 changes: 5 additions & 4 deletions cmd/crash.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ var crashCmd = &cobra.Command{
if device == nil {
os.Exit(0)
}
if !filepath.IsAbs(path) {
if !filepath.IsAbs(crashOutputPath) {
var err error
if path, err = filepath.Abs(path); err != nil {
if crashOutputPath, err = filepath.Abs(crashOutputPath); err != nil {
fmt.Println("path no found!")
os.Exit(0)
}
}
err := device.MoveCrashReport(path,
err := device.MoveCrashReport(crashOutputPath,
giDevice.WithKeepCrashReport(keep),
giDevice.WithExtractRawCrashReport(true),
giDevice.WithWhenMoveIsDone(func(filename string) {
Expand All @@ -57,10 +57,11 @@ var crashCmd = &cobra.Command{
}

var keep bool
var crashOutputPath string

func init() {
rootCmd.AddCommand(crashCmd)
crashCmd.Flags().StringVarP(&udid, "udid", "u", "", "device's serialNumber (default first device)")
crashCmd.Flags().BoolVarP(&keep, "keep", "k", false, "keep crash reports from device")
crashCmd.Flags().StringVarP(&path, "path", "p", "./", "output path")
crashCmd.Flags().StringVarP(&crashOutputPath, "path", "p", "./", "output path")
}

0 comments on commit d1fe924

Please sign in to comment.