Skip to content

Commit

Permalink
Merge pull request #16 from codeskyblue/fix_error_exit_code
Browse files Browse the repository at this point in the history
change error exit return code from 0 to 1
  • Loading branch information
electricbubble authored Nov 24, 2022
2 parents cdb0d74 + 27f82e0 commit 4980490
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cmd/launch.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package cmd

import (
"errors"
"fmt"

"github.com/electricbubble/gidevice-cli/internal"
"github.com/spf13/cobra"
)

// launchCmd represents the launch command
var launchCmd = &cobra.Command{
Use: "launch",
Use: "launch [-u udid] bundleID",
Short: "Launch application",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
internal.ErrorExit(errors.New("required parameter missing 'bundleID'"))
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return fmt.Errorf("required parameter missing 'bundleID'")
}
return nil
},
Run: func(cmd *cobra.Command, args []string) {
bundleID := args[0]
udid, _ := cmd.Flags().GetString("udid")

Expand Down
5 changes: 3 additions & 2 deletions internal/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package internal

import (
"errors"
giDevice "github.com/electricbubble/gidevice"
"log"
"os"
"strings"

giDevice "github.com/electricbubble/gidevice"
)

func GetDeviceFromCommand(udid string) (d giDevice.Device, err error) {
Expand All @@ -24,7 +25,7 @@ func ErrorExit(err error) {
} else {
log.Println(err)
}
os.Exit(0)
os.Exit(1)
}
}

Expand Down

0 comments on commit 4980490

Please sign in to comment.