From 7a4d11957a994765a467062dd5968ee96ce05c40 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Wed, 15 May 2024 06:41:25 -0500 Subject: [PATCH] Add a --list option that prints out server information without starting the UI --- stmps.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/stmps.go b/stmps.go index 3d63985..a2529f6 100644 --- a/stmps.go +++ b/stmps.go @@ -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 \n", os.Args[0]) @@ -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 {