gospt/runner/runner.go
jjohnstondev d81cf4d4e7 tracks
2023-01-07 16:57:51 -08:00

39 lines
844 B
Go

package runner
import (
"fmt"
"gospt/commands"
"gospt/ctx"
"gospt/tui"
"github.com/zmb3/spotify/v2"
)
func Run(ctx *ctx.Context, client *spotify.Client, args []string) error {
if len(args) == 0 {
user, err := client.CurrentUser(ctx)
if err != nil {
return fmt.Errorf("Failed to get current user")
}
fmt.Println("The following commands are currently supported:\nplay pause next shuffle\nhave fun", user.DisplayName)
return nil
}
switch args[0] {
case "play":
return commands.Play(ctx, client)
case "pause":
return commands.Pause(ctx, client)
case "next":
return commands.Skip(ctx, client)
case "shuffle":
return commands.Shuffle(ctx, client)
case "tracks":
return tui.DisplayList(ctx, client)
case "status":
return commands.Status(ctx, client)
default:
return fmt.Errorf("Unsupported Command")
}
}