-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
74 lines (60 loc) · 1.46 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
package main
import (
"context"
"fmt"
"os"
"github.com/dhulihan/grump/internal/config"
"github.com/dhulihan/grump/library"
"github.com/dhulihan/grump/player"
"github.com/dhulihan/grump/ui"
"github.com/sirupsen/logrus"
)
var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)
func main() {
ctx := context.Background()
c, err := config.Setup(ctx)
if err != nil {
logrus.WithError(err).Fatal("could not set up config")
}
if len(os.Args) < 2 {
help()
}
path := os.Args[1]
logrus.WithField("path", path).Info("starting up")
audioShelf, err := library.NewLocalAudioShelf(path)
if err != nil {
logrus.WithError(err).Fatal("could not set up audio library")
}
count, err := audioShelf.LoadTracks()
if err != nil {
logrus.WithError(err).Fatal("could not load audio library")
}
logrus.WithField("count", count).Info("loaded library")
audioShelves := []library.AudioShelf{audioShelf}
db, err := library.NewLibrary(audioShelves)
if err != nil {
logrus.WithError(err).Fatal("could not set up player db")
}
player, err := player.NewBeepAudioPlayer()
if err != nil {
logrus.WithError(err).Fatal("could not set up audio player")
}
build := ui.BuildInfo{
Version: version,
Commit: commit,
}
err = ui.Start(ctx, build, db, player, c.Loggers())
if err != nil {
logrus.WithError(err).Fatal("ui exited with an error")
}
}
func help() {
cmd := os.Args[0]
fmt.Printf("%s <file or directory>\n", cmd)
os.Exit(2)
}