-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.go
66 lines (59 loc) · 1.37 KB
/
get.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
package cmd
import (
"fmt"
"github.com/adamrdrew/mosh/ipc"
"github.com/adamrdrew/mosh/printer"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(getCommand)
getCommand.AddCommand(getPlayingCommand)
getCommand.AddCommand(getQueueCommand)
}
var getCommand = &cobra.Command{
Use: "get",
Short: "Get info ",
Long: `Get info on things like song, queue, etc`,
Aliases: []string{"g"},
}
var getPlayingCommand = &cobra.Command{
Use: "playing",
Short: "See what's playing",
Aliases: []string{"p", "pl"},
Long: `Get detailed info on what is currently playing`,
Run: func(cmd *cobra.Command, args []string) {
if !guardDaemonIsRunning() {
return
}
if !guardSetupCompleted() {
return
}
responseList := ipc.SendMessageToDaemon(ipc.Message{
Command: "now-playing",
})
response := responseList.First()
if response.Code == "OK" {
printer.NowPlaying(response)
} else {
fmt.Println(response.Message)
}
},
}
var getQueueCommand = &cobra.Command{
Use: "queue",
Short: "See the play queue",
Aliases: []string{"q", "qu"},
Long: `Get detailed info on the play queue`,
Run: func(cmd *cobra.Command, args []string) {
if !guardDaemonIsRunning() {
return
}
if !guardSetupCompleted() {
return
}
responseList := ipc.SendMessageToDaemon(ipc.Message{
Command: "get-queue",
})
printer.PlayQueue(responseList)
},
}