-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshow.go
More file actions
47 lines (41 loc) · 797 Bytes
/
show.go
File metadata and controls
47 lines (41 loc) · 797 Bytes
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
package main
// This file implements the "show" command
import (
"fmt"
)
func init() {
help["show"] = `Show various types of objects`
}
func (api API) Show(args []string) (resp, err string) {
for _, arg := range args {
str, ok := api.player.show(arg)
if !ok {
err += "show: not found: " + arg + "\n"
err += "options: library tree tags <tag>\n"
}
resp += str + "\n"
}
return
}
func (player *Player) show(str string) (resp string, ok bool) {
switch str {
default:
tag := player.FindTag(str)
if tag != nil {
resp = tag.Print(0)
} else {
ok = false
return
}
case "library":
resp = player.Lib.String()
case "tree":
resp = player.artists.Print(0)
case "tags":
for _, tag := range player.tags {
resp += fmt.Sprintln(tag)
}
}
ok = true
return
}