feat: restructure cli arguments

This commit is contained in:
2026-02-13 11:52:11 +01:00
parent 3f9ea7e56d
commit dee9a42ce2

36
main.go
View File

@@ -11,7 +11,7 @@ import (
) )
func main() { func main() {
var song_url, output_folder string var output_folder string
application := app.NewApp() application := app.NewApp()
@@ -20,23 +20,25 @@ func main() {
EnableShellCompletion: true, EnableShellCompletion: true,
DefaultCommand: "help", DefaultCommand: "help",
Usage: "Spotify downloader with playlist sync in mind.", Usage: "Spotify downloader with playlist sync in mind.",
Flags: []cli.Flag{ Commands: []*cli.Command{
&cli.StringFlag{ &cli.Command{
Name: "download", Name: "download",
Aliases: []string{"d"}, Aliases: []string{"d"},
Usage: "download a song/playlist", Usage: "download a song/playlist",
Destination: &song_url, Flags: []cli.Flag{
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "set output folder",
Destination: &output_folder,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
song_url := cmd.Args().First()
err := pkg.Download(application, song_url, output_folder)
return err
},
}, },
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "set output folder",
Destination: &output_folder,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
err := pkg.Download(application, song_url, output_folder)
return err
}, },
} }
if err := cmd.Run(context.Background(), os.Args); err != nil { if err := cmd.Run(context.Background(), os.Args); err != nil {