Add rate-skip command

This commit is contained in:
Dan Jones 2023-10-17 16:56:24 -05:00
commit cb655d29f5
3 changed files with 46 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
mpc-extra

31
cmd/rate-skip.go Normal file
View file

@ -0,0 +1,31 @@
/*
Copyright © 2023 Dan Jones
*/
package cmd
import (
"codeberg.org/danjones000/mpc-extra/mpd"
"github.com/spf13/cobra"
)
// rateSkipCmd represents the rate-skip command
var rateSkipCmd = &cobra.Command{
Use: "rate-skip [rating]",
Args: cobra.MinimumNArgs(1),
Short: "Rate the current song, and skip to the next",
RunE: func(cmd *cobra.Command, args []string) error {
root := cmd.Root()
root.SetArgs([]string{"current", "rate", "--", args[0]})
root.TraverseChildren = false
err := root.Execute()
if err != nil {
return err
}
return mpd.Next()
},
}
func init() {
rootCmd.AddCommand(rateSkipCmd)
}

View file

@ -20,3 +20,17 @@ func CloseConn() error {
}
return conn.Close()
}
func Next() error {
if connerror != nil {
return connerror
}
return conn.Next()
}
func Previous() error {
if connerror != nil {
return connerror
}
return conn.Previous()
}