v3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
abs3nt 2024-02-19 10:11:47 -08:00
parent f6f7d3bd70
commit 1faea3fd7f
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09
4 changed files with 57 additions and 69 deletions

View File

@ -5,9 +5,9 @@ _cli_zsh_autocomplete() {
local cur local cur
cur=${words[-1]} cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-shell-completion)}")
else else
opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}") opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-shell-completion)}")
fi fi
if [[ "${opts[1]}" != "" ]]; then if [[ "${opts[1]}" != "" ]]; then

5
go.mod
View File

@ -11,7 +11,7 @@ require (
github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/bubbletea v0.25.0
github.com/charmbracelet/lipgloss v0.9.1 github.com/charmbracelet/lipgloss v0.9.1
github.com/lmittmann/tint v1.0.4 github.com/lmittmann/tint v1.0.4
github.com/urfave/cli/v2 v2.27.1 github.com/urfave/cli/v3 v3.0.0-alpha9
github.com/zmb3/spotify/v2 v2.4.1 github.com/zmb3/spotify/v2 v2.4.1
go.uber.org/fx v1.20.1 go.uber.org/fx v1.20.1
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
@ -29,7 +29,6 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cristalhq/aconfig v0.18.5 // indirect github.com/cristalhq/aconfig v0.18.5 // indirect
github.com/cristalhq/aconfig/aconfigdotenv v0.17.1 // indirect github.com/cristalhq/aconfig/aconfigdotenv v0.17.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect
@ -53,9 +52,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7-0.20240127222946-601bbb3750c2 // indirect github.com/rivo/uniseg v0.4.7-0.20240127222946-601bbb3750c2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.opencensus.io v0.24.0 // indirect go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.7.0 // indirect go.uber.org/atomic v1.7.0 // indirect

8
go.sum
View File

@ -74,8 +74,6 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cristalhq/aconfig v0.17.0/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E= github.com/cristalhq/aconfig v0.17.0/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E=
github.com/cristalhq/aconfig v0.18.5 h1:QqXH/Gy2c4QUQJTV2BN8UAuL/rqZ3IwhvxeC8OgzquA= github.com/cristalhq/aconfig v0.18.5 h1:QqXH/Gy2c4QUQJTV2BN8UAuL/rqZ3IwhvxeC8OgzquA=
github.com/cristalhq/aconfig v0.18.5/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E= github.com/cristalhq/aconfig v0.18.5/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E=
@ -217,8 +215,6 @@ github.com/rivo/uniseg v0.4.7-0.20240127222946-601bbb3750c2 h1:tcc3ZFBvjydcgrAxa
github.com/rivo/uniseg v0.4.7-0.20240127222946-601bbb3750c2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.7-0.20240127222946-601bbb3750c2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wrYjDSCcZ78NoftLQyHBSLW/Cx79Y= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wrYjDSCcZ78NoftLQyHBSLW/Cx79Y=
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@ -233,8 +229,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v3 v3.0.0-alpha9 h1:P0RMy5fQm1AslQS+XCmy9UknDXctOmG/q/FZkUFnJSo=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/cli/v3 v3.0.0-alpha9/go.mod h1:0kK/RUFHyh+yIKSfWxwheGndfnrvYSmYFVeKCh03ZUc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

View File

@ -1,11 +1,12 @@
package cli package cli
import ( import (
"context"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v3"
"github.com/zmb3/spotify/v2" "github.com/zmb3/spotify/v2"
"go.uber.org/fx" "go.uber.org/fx"
@ -16,11 +17,11 @@ import (
var Version = "dev" var Version = "dev"
func Run(c *commands.Commander, s fx.Shutdowner) { func Run(c *commands.Commander, s fx.Shutdowner) {
app := &cli.App{ app := &cli.Command{
Name: "gspot", Name: "gspot",
EnableBashCompletion: true, EnableShellCompletion: true,
Version: Version, Version: Version,
Action: func(ctx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return tui.StartTea(c, "main") return tui.StartTea(c, "main")
}, },
Commands: []*cli.Command{ Commands: []*cli.Command{
@ -28,7 +29,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "play", Name: "play",
Aliases: []string{"pl", "start", "s"}, Aliases: []string{"pl", "start", "s"},
Usage: "Plays spotify", Usage: "Plays spotify",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Play() return c.Play()
}, },
Category: "Playback", Category: "Playback",
@ -37,10 +38,9 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "playurl", Name: "playurl",
Aliases: []string{"plu"}, Aliases: []string{"plu"},
Usage: "Plays a spotify url", Usage: "Plays a spotify url",
Args: true,
ArgsUsage: "url", ArgsUsage: "url",
Action: func(ctx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.PlayUrl(ctx.Args().First()) return c.PlayUrl(cmd.Args().First())
}, },
Category: "Playback", Category: "Playback",
}, },
@ -48,7 +48,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "pause", Name: "pause",
Aliases: []string{"pa"}, Aliases: []string{"pa"},
Usage: "Pauses spotify", Usage: "Pauses spotify",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Pause() return c.Pause()
}, },
Category: "Playback", Category: "Playback",
@ -57,7 +57,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "toggleplay", Name: "toggleplay",
Aliases: []string{"t"}, Aliases: []string{"t"},
Usage: "Toggles play/pause", Usage: "Toggles play/pause",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.TogglePlay() return c.TogglePlay()
}, },
Category: "Playback", Category: "Playback",
@ -66,7 +66,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "link", Name: "link",
Aliases: []string{"yy"}, Aliases: []string{"yy"},
Usage: "Prints the current song's spotify link", Usage: "Prints the current song's spotify link",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.PrintLink() return c.PrintLink()
}, },
Category: "Sharing", Category: "Sharing",
@ -75,7 +75,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "linkcontext", Name: "linkcontext",
Aliases: []string{"lc"}, Aliases: []string{"lc"},
Usage: "Prints the current album or playlist", Usage: "Prints the current album or playlist",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.PrintLinkContext() return c.PrintLinkContext()
}, },
Category: "Sharing", Category: "Sharing",
@ -84,7 +84,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "youtube-link", Name: "youtube-link",
Aliases: []string{"yl"}, Aliases: []string{"yl"},
Usage: "Prints the current song's youtube link", Usage: "Prints the current song's youtube link",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.PrintYoutubeLink() return c.PrintYoutubeLink()
}, },
Category: "Sharing", Category: "Sharing",
@ -93,11 +93,10 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "next", Name: "next",
Aliases: []string{"n", "skip"}, Aliases: []string{"n", "skip"},
Usage: "Skips to the next song", Usage: "Skips to the next song",
Args: true,
ArgsUsage: "amount", ArgsUsage: "amount",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
if cCtx.NArg() > 0 { if cmd.NArg() > 0 {
amt, err := strconv.Atoi(cCtx.Args().First()) amt, err := strconv.Atoi(cmd.Args().First())
if err != nil { if err != nil {
return err return err
} }
@ -111,7 +110,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "previous", Name: "previous",
Aliases: []string{"b", "prev", "back"}, Aliases: []string{"b", "prev", "back"},
Usage: "Skips to the previous song", Usage: "Skips to the previous song",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Previous() return c.Previous()
}, },
Category: "Playback", Category: "Playback",
@ -120,7 +119,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "like", Name: "like",
Aliases: []string{"l"}, Aliases: []string{"l"},
Usage: "Likes the current song", Usage: "Likes the current song",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Like() return c.Like()
}, },
Category: "Library Management", Category: "Library Management",
@ -129,7 +128,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "unlike", Name: "unlike",
Aliases: []string{"u"}, Aliases: []string{"u"},
Usage: "Unlikes the current song", Usage: "Unlikes the current song",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.UnLike() return c.UnLike()
}, },
Category: "Library Management", Category: "Library Management",
@ -146,8 +145,8 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Usage: "bypass cache", Usage: "bypass cache",
}, },
}, },
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.NowPlaying(cCtx.Bool("force")) return c.NowPlaying(cmd.Bool("force"))
}, },
Category: "Info", Category: "Info",
}, },
@ -156,14 +155,13 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Aliases: []string{"v"}, Aliases: []string{"v"},
Usage: "Control the volume", Usage: "Control the volume",
Category: "Playback", Category: "Playback",
Subcommands: []*cli.Command{ Commands: []*cli.Command{
{ {
Name: "up", Name: "up",
Usage: "Increase the volume", Usage: "Increase the volume",
Args: true,
ArgsUsage: "percent", ArgsUsage: "percent",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
amt, err := strconv.Atoi(cCtx.Args().First()) amt, err := strconv.Atoi(cmd.Args().First())
if err != nil { if err != nil {
return err return err
} }
@ -174,10 +172,9 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "down", Name: "down",
Aliases: []string{"dn"}, Aliases: []string{"dn"},
Usage: "Decrease the volume", Usage: "Decrease the volume",
Args: true,
ArgsUsage: "percent", ArgsUsage: "percent",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
amt, err := strconv.Atoi(cCtx.Args().First()) amt, err := strconv.Atoi(cmd.Args().First())
if err != nil { if err != nil {
return err return err
} }
@ -188,7 +185,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "mute", Name: "mute",
Aliases: []string{"m"}, Aliases: []string{"m"},
Usage: "Mute", Usage: "Mute",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Mute() return c.Mute()
}, },
}, },
@ -196,7 +193,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "unmute", Name: "unmute",
Aliases: []string{"um"}, Aliases: []string{"um"},
Usage: "Unmute", Usage: "Unmute",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.UnMute() return c.UnMute()
}, },
}, },
@ -204,7 +201,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "togglemute", Name: "togglemute",
Aliases: []string{"tm"}, Aliases: []string{"tm"},
Usage: "Toggle mute", Usage: "Toggle mute",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.ToggleMute() return c.ToggleMute()
}, },
}, },
@ -214,15 +211,14 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "download_cover", Name: "download_cover",
Usage: "Downloads the cover of the current song", Usage: "Downloads the cover of the current song",
Aliases: []string{"dl"}, Aliases: []string{"dl"},
Args: true,
ArgsUsage: "path", ArgsUsage: "path",
BashComplete: func(cCtx *cli.Context) { ShellComplete: func(ctx context.Context, cmd *cli.Command) {
if cCtx.NArg() > 0 { if cmd.NArg() > 0 {
return return
} }
}, },
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.DownloadCover(cCtx.Args().First()) return c.DownloadCover(cmd.Args().First())
}, },
Category: "Info", Category: "Info",
}, },
@ -230,7 +226,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "radio", Name: "radio",
Usage: "Starts a radio from the current song", Usage: "Starts a radio from the current song",
Aliases: []string{"r"}, Aliases: []string{"r"},
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Radio() return c.Radio()
}, },
Category: "Radio", Category: "Radio",
@ -239,7 +235,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "clearradio", Name: "clearradio",
Usage: "Clears the radio queue", Usage: "Clears the radio queue",
Aliases: []string{"cr"}, Aliases: []string{"cr"},
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.ClearRadio() return c.ClearRadio()
}, },
Category: "Radio", Category: "Radio",
@ -248,7 +244,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "refillradio", Name: "refillradio",
Usage: "Refills the radio queue with similar songs", Usage: "Refills the radio queue with similar songs",
Aliases: []string{"rr"}, Aliases: []string{"rr"},
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.RefillRadio() return c.RefillRadio()
}, },
Category: "Radio", Category: "Radio",
@ -256,7 +252,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
{ {
Name: "status", Name: "status",
Usage: "Prints the current status", Usage: "Prints the current status",
Action: func(ctx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Status() return c.Status()
}, },
Category: "Info", Category: "Info",
@ -265,7 +261,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "devices", Name: "devices",
Usage: "Lists available devices", Usage: "Lists available devices",
Aliases: []string{"d"}, Aliases: []string{"d"},
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.ListDevices() return c.ListDevices()
}, },
Category: "Info", Category: "Info",
@ -273,20 +269,19 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
{ {
Name: "setdevice", Name: "setdevice",
Usage: "Set the active device", Usage: "Set the active device",
Args: true,
ArgsUsage: "<device_id>", ArgsUsage: "<device_id>",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
if cCtx.NArg() == 0 { if cmd.NArg() == 0 {
return fmt.Errorf("no device id provided") return fmt.Errorf("no device id provided")
} }
return c.SetDevice(spotify.ID(cCtx.Args().First())) return c.SetDevice(spotify.ID(cmd.Args().First()))
}, },
Category: "Playback", Category: "Playback",
}, },
{ {
Name: "repeat", Name: "repeat",
Usage: "Toggle repeat mode", Usage: "Toggle repeat mode",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Repeat() return c.Repeat()
}, },
Category: "Playback", Category: "Playback",
@ -294,7 +289,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
{ {
Name: "shuffle", Name: "shuffle",
Usage: "Toggle shuffle mode", Usage: "Toggle shuffle mode",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Shuffle() return c.Shuffle()
}, },
Category: "Playback", Category: "Playback",
@ -302,7 +297,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
{ {
Name: "tui", Name: "tui",
Usage: "Starts the TUI", Usage: "Starts the TUI",
Action: func(ctx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return tui.StartTea(c, "main") return tui.StartTea(c, "main")
}, },
}, },
@ -311,19 +306,19 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Usage: "Seek to a position in the song", Usage: "Seek to a position in the song",
Aliases: []string{"sk"}, Aliases: []string{"sk"},
Category: "Playback", Category: "Playback",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
pos, err := strconv.Atoi(cCtx.Args().First()) pos, err := strconv.Atoi(cmd.Args().First())
if err != nil { if err != nil {
return err return err
} }
return c.SetPosition(pos) return c.SetPosition(pos)
}, },
Subcommands: []*cli.Command{ Commands: []*cli.Command{
{ {
Name: "forward", Name: "forward",
Aliases: []string{"f"}, Aliases: []string{"f"},
Usage: "Seek forward", Usage: "Seek forward",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Seek(true) return c.Seek(true)
}, },
}, },
@ -331,7 +326,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "backward", Name: "backward",
Aliases: []string{"b"}, Aliases: []string{"b"},
Usage: "Seek backward", Usage: "Seek backward",
Action: func(cCtx *cli.Context) error { Action: func(ctx context.Context, cmd *cli.Command) error {
return c.Seek(false) return c.Seek(false)
}, },
}, },
@ -339,7 +334,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
}, },
}, },
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(c.Context, os.Args); err != nil {
c.Log.Error("COMMANDER", "run error", err) c.Log.Error("COMMANDER", "run error", err)
s.Shutdown(fx.ExitCode(1)) s.Shutdown(fx.ExitCode(1))
} }