-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (37 loc) · 856 Bytes
/
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
package main
import (
"fmt"
"strings"
"os"
"sync"
"github.com/brunohgv/adbatch/adb"
"github.com/brunohgv/adbatch/runner"
)
func main() {
arguments := os.Args[1:]
if len(arguments) == 0 {
fmt.Println("Adbatch is working!")
fmt.Println("Run an adb command using adbatch to broadcast it to all connected devices.")
} else {
command := strings.Join(arguments, " ")
deviceIds := adb.GetDevices()
outputDir, err := os.Getwd()
if err != nil {
panic("Could not locate the current directory")
}
var wg sync.WaitGroup
for _, deviceId := range deviceIds {
wg.Add(1)
go func(deviceId string) {
defer wg.Done()
process := runner.Process{
Command: command,
DeviceId: deviceId,
FilePath: outputDir,
}
process.Run()
}(deviceId)
}
wg.Wait()
}
}