flags
This commit is contained in:
parent
7ecb57a8fd
commit
8fccb0886f
@ -99,10 +99,16 @@ 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)
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user