feat(cli): simplify output for individual songs

This commit is contained in:
Mathis Maquenne
2025-09-10 11:10:52 +02:00
parent 9b23e3a8d9
commit c2b4fcfa11
4 changed files with 27 additions and 25 deletions
+16 -8
View File
@@ -75,6 +75,9 @@ func (c *Client) Run(ctx context.Context, opts Options, id string) error {
songs := resource.GetSongs()
if len(songs) == 0 {
if c.resourceType == "track" {
return fmt.Errorf("track with ID %s not found", id)
}
return fmt.Errorf("%s has no songs", c.resourceType)
}
if c.resourceType == "artist" && len(songs) > opts.Limit {
@@ -89,7 +92,9 @@ func (c *Client) Run(ctx context.Context, opts Options, id string) error {
}
startTime := time.Now()
fmt.Printf("%s\n\nStarting download...\n\n", resource)
if c.resourceType != "track" {
fmt.Printf("%s\n\nStarting download...\n\n", resource)
}
downloaded := 0
skipped := 0
@@ -147,7 +152,9 @@ func (c *Client) Run(ctx context.Context, opts Options, id string) error {
if downloaded > 0 || failed > 0 {
c.Logger.Infof("Playlist %s (%s): %d downloaded, %d skipped, %d failed\n", resource.GetTitle(), id, downloaded, skipped, failed)
}
fmt.Printf(`
if c.resourceType != "track" {
fmt.Printf(`
================== [ Summary ] ==================
Downloaded: %d
Skipped: %d
@@ -156,12 +163,13 @@ Elapsed time: %s
Files saved to: %s
=================================================
`,
downloaded,
skipped,
failed,
time.Since(startTime).Round(time.Second),
resourceOutputDir,
)
downloaded,
skipped,
failed,
time.Since(startTime).Round(time.Second),
resourceOutputDir,
)
}
return nil
}