improved shell
This commit is contained in:
@@ -12,9 +12,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func printResults(musicObjects []data.MusicObject) {
|
func printResults(musicObjects []data.MusicObject) {
|
||||||
|
if len(musicObjects) <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, m := range musicObjects {
|
for _, m := range musicObjects {
|
||||||
if a, ok := m.(data.Artist); ok {
|
if a, ok := m.(data.Artist); ok {
|
||||||
fmt.Println("artist: " + a.Name)
|
fmt.Println("artist: " + a.Name)
|
||||||
|
|
||||||
} else if a, ok := m.(data.Album); ok {
|
} else if a, ok := m.(data.Album); ok {
|
||||||
fmt.Print("release: " + a.Name)
|
fmt.Print("release: " + a.Name)
|
||||||
|
|
||||||
@@ -27,15 +32,30 @@ func printResults(musicObjects []data.MusicObject) {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if a, ok := m.(data.Song); ok {
|
} else if a, ok := m.(data.Song); ok {
|
||||||
fmt.Println("track: " + a.Name)
|
fmt.Print("track: " + a.Name)
|
||||||
|
if len(a.Artists) > 0 {
|
||||||
|
names := make([]string, len(a.Artists))
|
||||||
|
for i, artist := range a.Artists {
|
||||||
|
names[i] = artist.Name
|
||||||
|
}
|
||||||
|
fmt.Println(" by " + strings.Join(names, ", "))
|
||||||
|
} else {
|
||||||
|
fmt.Println()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Shell() {
|
func Shell() {
|
||||||
plugin.RegisterPlugin(&plugin.Musify{})
|
plugin.RegisterPlugin(&plugin.Musify{})
|
||||||
|
|
||||||
|
fmt.Println("== MusicKraken Shell ==")
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Print("> ")
|
fmt.Print("> ")
|
||||||
|
|
||||||
@@ -54,6 +74,5 @@ func Shell() {
|
|||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
printResults(searchResults)
|
printResults(searchResults)
|
||||||
fmt.Println()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user