Skip to content

Commit

Permalink
Merge pull request #3 from xxxserxxx/list-command
Browse files Browse the repository at this point in the history
Add a --list option that prints out server information
  • Loading branch information
spezifisch authored Jul 30, 2024
2 parents 581b478 + 7a4d119 commit b9c5eb7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions stmps.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func readConfig() {
func main() {
help := flag.Bool("help", false, "Print usage")
enableMpris := flag.Bool("mpris", false, "Enable MPRIS2")
list := flag.Bool("list", false, "list server data")
flag.Parse()
if *help {
fmt.Printf("USAGE: %s <args>\n", os.Args[0])
Expand Down Expand Up @@ -70,6 +71,37 @@ func main() {
os.Exit(1)
}

if *list {
fmt.Printf("Index response:\n")
fmt.Printf(" Directory: %s\n", indexResponse.Directory.Name)
fmt.Printf(" Status: %s\n", indexResponse.Status)
fmt.Printf(" Error: %s\n", indexResponse.Error.Message)
fmt.Printf(" Playlist: %s\n", indexResponse.Playlist.Name)
fmt.Printf(" Playlists: (%d)\n", len(indexResponse.Playlists.Playlists))
for _, pl := range indexResponse.Playlists.Playlists {
fmt.Printf(" [%d] %s\n", pl.Entries.Len(), pl.Name)
}
fmt.Printf(" Indexes:\n")
for _, pl := range indexResponse.Indexes.Index {
fmt.Printf(" %s\n", pl.Name)
}
fmt.Printf("Playlist response:\n")
fmt.Printf(" Directory: %s\n", playlistResponse.Directory.Name)
fmt.Printf(" Status: %s\n", playlistResponse.Status)
fmt.Printf(" Error: %s\n", playlistResponse.Error.Message)
fmt.Printf(" Playlist: %s\n", playlistResponse.Playlist.Name)
fmt.Printf(" Playlists: (%d)\n", len(indexResponse.Playlists.Playlists))
for _, pl := range playlistResponse.Playlists.Playlists {
fmt.Printf(" [%d] %s\n", pl.Entries.Len(), pl.Name)
}
fmt.Printf(" Indexes:\n")
for _, pl := range playlistResponse.Indexes.Index {
fmt.Printf(" %s\n", pl.Name)
}

os.Exit(0)
}

// init mpv engine
player, err := mpvplayer.NewPlayer(logger)
if err != nil {
Expand Down

0 comments on commit b9c5eb7

Please sign in to comment.