feat: download artist's top tracks with --limit flag

This commit is contained in:
Mathis Maquenne
2025-06-20 20:00:59 -04:00
parent 1fdd0e8c19
commit 67b4fe404e
8 changed files with 136 additions and 12 deletions
+12 -1
View File
@@ -27,13 +27,19 @@ func init() {
downloadCmd.AddCommand(
newDownloadCmd("album"),
newDownloadCmd("playlist"),
newDownloadCmd("artist"),
)
}
func newDownloadCmd(resourceType string) *cobra.Command {
article := "a"
if resourceType == "album" {
article = "an"
}
cmd := &cobra.Command{
Use: fmt.Sprintf("%s <%s_id>", resourceType, resourceType),
Short: fmt.Sprintf("Download songs from %s", resourceType),
Short: fmt.Sprintf("Download songs from %s %s", article, resourceType),
Args: cobra.ExactArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate()
@@ -54,5 +60,10 @@ func newDownloadCmd(resourceType string) *cobra.Command {
},
}
if resourceType == "artist" {
cmd.Flags().IntVarP(&opts.Limit, "limit", "l", 10, "number of songs to download")
cmd.Short = fmt.Sprintf("Download top songs from an artist")
}
return cmd
}