mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-19 15:23:36 +00:00
refactor(cli): simplify parseArtworkKind with slices.Contains
Replaces a nested loop and a manual append with slices.Contains and the repo's slice.Map helper. Same behaviour, same error message.
This commit is contained in:
1 parent
8e1ed55ca6
commit
46a332757f
1 file changed
+3
-10
+3
-10
@@ -493,17 +493,10 @@ func refreshItems(ctx context.Context, ds model.DataStore, kind model.Kind, ids
|
||||
|
||||
func parseArtworkKind(s string) (model.Kind, error) {
|
||||
kind, ok := model.ParseKind(s)
|
||||
if ok {
|
||||
for _, k := range artworkKinds {
|
||||
if k == kind {
|
||||
return kind, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
valid := make([]string, 0, len(artworkKinds))
|
||||
for _, k := range artworkKinds {
|
||||
valid = append(valid, k.Prefix())
|
||||
if ok && slices.Contains(artworkKinds, kind) {
|
||||
return kind, nil
|
||||
}
|
||||
valid := slice.Map(artworkKinds, func(k model.Kind) string { return k.Prefix() })
|
||||
return kind, fmt.Errorf("invalid kind %q, expected one of: %s", s, strings.Join(valid, ", "))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user