✨ Add rate-skip command
This commit is contained in:
parent
b2dd7b321a
commit
cb655d29f5
3 changed files with 46 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mpc-extra
|
||||||
31
cmd/rate-skip.go
Normal file
31
cmd/rate-skip.go
Normal 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)
|
||||||
|
}
|
||||||
14
mpd/conn.go
14
mpd/conn.go
|
|
@ -20,3 +20,17 @@ func CloseConn() error {
|
||||||
}
|
}
|
||||||
return conn.Close()
|
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()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue