✨ PrintAll method
This commit is contained in:
parent
942d419bf6
commit
440b927141
3 changed files with 19 additions and 13 deletions
|
|
@ -4,8 +4,6 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"codeberg.org/danjones000/mpc-extra/mpd"
|
"codeberg.org/danjones000/mpc-extra/mpd"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
@ -22,13 +20,7 @@ This application is a tool to generate the needed files
|
||||||
to quickly create a Cobra application.`,
|
to quickly create a Cobra application.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
curr, _ := mpd.GetCurrent()
|
curr, _ := mpd.GetCurrent()
|
||||||
for k, v := range curr.Attrs {
|
curr.PrintAll(true)
|
||||||
fmt.Println(k, ":", v)
|
|
||||||
}
|
|
||||||
sticks, _ := curr.GetStickers()
|
|
||||||
for _, v := range sticks {
|
|
||||||
fmt.Println(v.Name, "*:", v.Value)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,7 @@ to quickly create a Cobra application.`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
ret, _ := mpd.Find(args...)
|
ret, _ := mpd.Find(args...)
|
||||||
for _, song := range ret {
|
for _, song := range ret {
|
||||||
for k, v := range song.Attrs {
|
song.PrintAll(false)
|
||||||
fmt.Println(k, ":", v)
|
|
||||||
}
|
|
||||||
fmt.Println("-------")
|
fmt.Println("-------")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
18
mpd/song.go
18
mpd/song.go
|
|
@ -1,6 +1,9 @@
|
||||||
package mpd
|
package mpd
|
||||||
|
|
||||||
import "github.com/fhs/gompd/v2/mpd"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/fhs/gompd/v2/mpd"
|
||||||
|
)
|
||||||
|
|
||||||
type Song struct {
|
type Song struct {
|
||||||
Path string
|
Path string
|
||||||
|
|
@ -29,3 +32,16 @@ func (s *Song) GetStickers() ([]mpd.Sticker, error) {
|
||||||
|
|
||||||
return s.stickers, err
|
return s.stickers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Song) PrintAll(withStickers bool) {
|
||||||
|
for k, v := range s.Attrs {
|
||||||
|
fmt.Println(k, ":", v)
|
||||||
|
}
|
||||||
|
if withStickers {
|
||||||
|
sticks, _ := s.GetStickers()
|
||||||
|
for _, v := range sticks {
|
||||||
|
fmt.Println(v.Name, "*:", v.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue