shitty help menu
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
jjohnstondev 2023-01-08 22:50:27 -08:00
parent 052bf1cef6
commit 78ab7fe95d
5 changed files with 22 additions and 4 deletions

View File

@ -2,6 +2,8 @@ package api
import (
"fmt"
"os"
"path/filepath"
"gospt/internal/commands"
"gospt/internal/gctx"
@ -12,9 +14,15 @@ import (
func Run(ctx *gctx.Context, client *spotify.Client, args []string) error {
if len(args) == 0 {
configDir, _ := os.UserConfigDir()
if _, err := os.Stat(filepath.Join(configDir, "gospt/device.json")); err != nil {
return tui.DisplayDevices(ctx, client)
}
return tui.DisplayMain(ctx, client)
}
switch args[0] {
case "help", "--help":
return commands.PrintHelp(ctx)
case "play":
return commands.Play(ctx, client)
case "pause":

View File

@ -16,6 +16,14 @@ import (
"github.com/zmb3/spotify/v2"
)
func PrintHelp(ctx *gctx.Context) error {
fmt.Println("Usage: gospt [command]")
fmt.Println("if no command is provided then TUI will open")
fmt.Println("\ncurrently available commands:")
fmt.Println("help, play, pause, toggleplay, \nnext, previous, playurl, like, unlike, shuffle, \nrepeat, radio, clearradio, refillradio, tracks, \nclearradio, playlists, status, devices, nowplaying, setdevice")
return nil
}
func Play(ctx *gctx.Context, client *spotify.Client) error {
err := client.Play(ctx)
if err != nil {

View File

@ -43,14 +43,16 @@ func (m deviceModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit
}
if msg.String() == "enter" {
fmt.Println("SELECTING")
device := m.list.SelectedItem()
var err error
err = commands.SetDevice(m.ctx, m.client, device.(deviceItem).PlayerDevice)
if err != nil {
m.ctx.Printf(err.Error())
}
fmt.Println("DEVICE SET")
err = DisplayMain(m.ctx, m.client)
if err != nil {
return m, tea.Quit
}
return m, tea.Quit
}
case tea.MouseMsg:

View File

@ -118,7 +118,7 @@ func DisplayMain(ctx *gctx.Context, client *spotify.Client) error {
ctx: ctx,
client: client,
}
m.list.Title = "Saved Tracks"
m.list.Title = "GOSPT"
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithMouseCellMotion())

View File

@ -134,7 +134,7 @@ func PlaylistTracks(ctx *gctx.Context, client *spotify.Client, playlist spotify.
client: client,
playlist: playlist,
}
m.list.Title = "Saved Tracks"
m.list.Title = playlist.Name
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithMouseCellMotion())