diff --git a/go.mod b/go.mod index a52932e..6e88587 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,7 @@ module github.com/codeskyblue/fa require ( github.com/cavaliercoder/grab v2.0.0+incompatible + github.com/kr/pty v1.1.1 github.com/manifoldco/promptui v0.3.2 github.com/mattn/go-runewidth v0.0.3 // indirect github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 diff --git a/install.go b/install.go index 17d57c5..1fb21c2 100644 --- a/install.go +++ b/install.go @@ -10,6 +10,7 @@ import ( "time" "github.com/cavaliercoder/grab" + "github.com/kr/pty" "github.com/pkg/errors" "github.com/shogo82148/androidbinary/apk" "github.com/urfave/cli" @@ -90,10 +91,14 @@ func actInstall(ctx *cli.Context) error { // install outBuffer := bytes.NewBuffer(nil) - c := adbCommand(serial, "install", apkpath) - c.Stdout = io.MultiWriter(os.Stdout, outBuffer) - c.Stderr = os.Stderr - if err := c.Run(); err != nil { + c := adbCommand(serial, "install", "-r", apkpath) + ttyf, err := pty.Start(c) + if err != nil { + return err + } + mwr := io.MultiWriter(os.Stdout, outBuffer) + io.Copy(mwr, ttyf) + if err := c.Wait(); err != nil { return err }