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

This commit is contained in:
abs3nt 2024-02-18 10:23:19 -08:00
parent 7ecb57a8fd
commit 8fccb0886f
Signed by: abs3nt
GPG Key ID: A7BD96A8BAB04C09
2 changed files with 16 additions and 6 deletions

View File

@ -99,10 +99,16 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
Name: "download_cover",
Usage: "Downloads the cover of the current song",
Aliases: []string{"dl"},
Args: true,
ArgsUsage: "download_cover <path>",
Flags: []cli.Flag{
&cli.PathFlag{
Name: "path",
Aliases: []string{"p"},
Usage: "Path to save the cover",
DefaultText: "./cover.png",
},
},
Action: func(cCtx *cli.Context) error {
return c.DownloadCover(cCtx.Args().First())
return c.DownloadCover(cCtx.Path("path"))
},
},
{
@ -115,6 +121,7 @@ func Run(c *commands.Commander, s fx.Shutdowner) {
},
},
}
app.Suggest = true
if err := app.Run(os.Args); err != nil {
slog.Error("COMMANDER", "run error", err)
os.Exit(1)

View File

@ -6,6 +6,9 @@ import (
)
func (c *Commander) DownloadCover(path string) error {
if path == "" {
path = "cover.png"
}
destinationPath := filepath.Clean(path)
state, err := c.Client.PlayerState(c.Context)
if err != nil {