-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (41 loc) · 1.25 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
package main
import (
"flag"
"fmt"
"github.com/robopuff/goradio/pkg/gui/minimal"
"log"
"os/user"
"github.com/robopuff/goradio/pkg/drivers"
"github.com/robopuff/goradio/pkg/gui"
"github.com/robopuff/goradio/pkg/gui/termui"
"github.com/robopuff/goradio/pkg/stations"
)
func main() {
usr, _ := user.Current()
flagStations := flag.String("s", fmt.Sprintf("%s/.config/pyradio/stations.csv", usr.HomeDir), "Stations file path")
flagMplayer := flag.String("m", "mplayer", "MPlayer executable")
flagDebugMode := flag.Bool("d", false, "Debug mode (shows logger window)")
flagMinimal := flag.Bool("minimal", false, "Use minimal ui")
flag.Parse()
d := drivers.NewMPlayer(*flagMplayer)
if err := d.CheckPrerequisites(); err != nil {
log.Fatalf("system failed drivers prerequisites check: %v", err)
}
s, err := stations.Load(*flagStations)
if err != nil {
log.Fatalf("cannot load or download stations list: %v", err)
}
var userInterface gui.GUI
userInterface = termui.NewTermUI(s, *flagDebugMode)
if *flagMinimal {
userInterface = minimal.NewMinimal(s, *flagDebugMode)
}
defer (func() {
d.Close()
userInterface.Close()
})()
if err := userInterface.Init(); err != nil {
log.Fatalf("failed to initialize gui: %v", err)
}
userInterface.Run(d)
}