-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
83 lines (68 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"os"
"os/signal"
"path/filepath"
"syscall"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
initAPath string
initLPath string
initSelPath string
initAuxPath string
initSelMode ifaceMode
initAuxMode ifaceMode
)
func main() {
cmdAPath := kingpin.Flag("remote", "Specify the remote path to start in").
Default("/sdcard").String()
cmdLPath := kingpin.Flag("local", "Specify the local path to start in").
Default("/home").String()
kingpin.Parse()
_, err := os.Lstat(*cmdLPath)
if err != nil {
fmt.Printf("adbtuifm: %s: Invalid local path\n", *cmdLPath)
return
}
initSelMode = mLocal
initSelPath, _ = filepath.Abs(*cmdLPath)
device, err := getAdb()
if device != nil {
_, err := device.Stat(*cmdAPath)
if err != nil {
fmt.Printf("adbtuifm: %s: Invalid remote path\n", *cmdAPath)
return
}
initAuxMode = mAdb
initAuxPath = *cmdAPath
} else {
initAuxMode = mLocal
initAuxPath = initSelPath
}
initAPath = *cmdAPath
initLPath, _ = filepath.Abs(*cmdLPath)
jobNum = 0
selected = false
openFiles = make(map[string]struct{})
multiselection = make(map[string]ifaceMode)
sig := make(chan os.Signal, 1)
signal.Notify(
sig,
os.Interrupt,
syscall.SIGHUP,
syscall.SIGQUIT,
syscall.SIGTERM,
)
go func(s chan os.Signal) {
switch <-s {
case os.Interrupt:
return
default:
stopUI()
return
}
}(sig)
setupUI()
}