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

@ -96,13 +96,19 @@ 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, Flags: []cli.Flag{
ArgsUsage: "download_cover <path>", &cli.PathFlag{
Name: "path",
Aliases: []string{"p"},
Usage: "Path to save the cover",
DefaultText: "./cover.png",
},
},
Action: func(cCtx *cli.Context) error { 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 { if err := app.Run(os.Args); err != nil {
slog.Error("COMMANDER", "run error", err) slog.Error("COMMANDER", "run error", err)
os.Exit(1) os.Exit(1)

View File

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