File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99- [x] install support http url
1010- [x] support launch after install apk
1111- [x] support ` fa devices --json `
12+ - [x] support ` fa shell `
1213- [ ] install apk and auto click confirm
1314- [ .] check device health status
1415- [ ] show current app
@@ -99,6 +100,16 @@ Launch io.appium.android.apis ...
99100+ adb -s 0123456789ABCDEF shell am start -n io.appium.android.apis/.ApiDemos
100101` ` `
101102
103+ # ## Shell
104+ Like ` adb shell` , run ` fa shell` will open a terminal
105+
106+ The difference is ` fa shell` will add ` /data/local/tmp` into ` $PATH `
107+ So if you have binary ` busybox` in ` /data/local/tmp` ,
108+ You can just run
109+
110+ ` ` `
111+ fa shell busybox ls
112+ ` ` `
102113
103114# # Reference
104115Articles
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ require (
77 github.com/kr/pty v1.1.3 // indirect
88 github.com/manifoldco/promptui v0.3.2
99 github.com/mattn/go-runewidth v0.0.3 // indirect
10+ github.com/mattn/go-tty v0.0.0-20181127064339-e4f871175a2f
1011 github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
1112 github.com/pkg/errors v0.8.0
1213 github.com/shogo82148/androidbinary v0.0.0-20180627093851-01c4bfa8b3b5
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import (
1313 "strings"
1414 "syscall"
1515
16+ shellquote "github.com/kballard/go-shellquote"
17+ tty "github.com/mattn/go-tty"
18+
1619 "github.com/manifoldco/promptui"
1720 cli "gopkg.in/urfave/cli.v1"
1821)
@@ -267,7 +270,7 @@ func main() {
267270 Name : "install" ,
268271 Usage : "install apk" ,
269272 UsageText : "fa install [ul] <apk-file | url>" ,
270- // UseShortOptionHandling: true,
273+ // UseShortOptionHandling: true, // not supported in current urfav/cli
271274 Flags : []cli.Flag {
272275 cli.BoolFlag {
273276 Name : "force, f" ,
@@ -290,16 +293,24 @@ func main() {
290293 return err
291294 }
292295 device := DefaultAdbClient .DeviceWithSerial (serial )
293- rwc , err := device .OpenCommand (ctx .Args ()... )
296+
297+ var cmd string
298+ if len (ctx .Args ()) != 0 {
299+ cmd = `PATH="$PATH:/data/local/tmp" ` + shellquote .Join (ctx .Args ()... )
300+ }
301+ rwc , err := device .OpenShell (cmd )
294302 if err != nil {
295303 return err
296304 }
297305 defer rwc .Close ()
298- go io .Copy (rwc , os .Stdin )
299- io .Copy (os .Stdout , rwc )
300- // fmt.Print(output)
301- // os.Exit(exitCode)
302- return nil
306+ tty , err := tty .Open ()
307+ if err != nil {
308+ log .Fatal (err )
309+ }
310+ defer tty .Close ()
311+ go io .Copy (rwc , tty .Input ())
312+ _ , err = io .Copy (tty .Output (), rwc )
313+ return err
303314 },
304315 },
305316 {
You can’t perform that action at this time.
0 commit comments