refactor: validate limit only for artist downloads

This commit is contained in:
Mathis Maquenne
2026-08-05 12:42:51 +02:00
parent e90a56ec53
commit 5bb1448650
3 changed files with 28 additions and 21 deletions
+1 -3
View File
@@ -28,8 +28,6 @@ func newDownloadCmd() *cobra.Command {
cmd.PersistentFlags().BoolVar(&opts.Genre, "genre", false, "fetch genre and add to file tags")
cmd.PersistentFlags().BoolVar(&opts.Strict, "strict", false, "fail the download if the requested quality is unavailable")
// Every subcommand shares opts: registering the artist-only --limit flag
// stores its default in the shared struct, which Validate requires for all kinds.
cmd.AddCommand(
newDownloadSubCmd(deezer.KindAlbum, opts),
newDownloadSubCmd(deezer.KindPlaylist, opts),
@@ -47,7 +45,7 @@ func newDownloadSubCmd(kind deezer.Kind, opts *download.Options) *cobra.Command
Args: cobra.ExactArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.Quality = strings.ToLower(opts.Quality)
return opts.Validate()
return opts.Validate(kind)
},
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := config.Load()