Skip to content

Commit 17de7ab

Browse files
committed
Improved implementation of sketch.GetSketchProfiles
1 parent 9ad2f91 commit 17de7ab

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

internal/cli/arguments/sketch.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020

2121
"github.com/arduino/arduino-cli/commands/sketch"
22+
f "github.com/arduino/arduino-cli/internal/algorithms"
2223
"github.com/arduino/arduino-cli/internal/cli/feedback"
2324
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2425
"github.com/arduino/go-paths-helper"
@@ -57,13 +58,10 @@ func GetSketchProfiles(sketchPath string) []string {
5758
return nil
5859
}
5960
}
60-
list, _ := sketch.LoadSketch(context.Background(), &rpc.LoadSketchRequest{
61-
SketchPath: sketchPath,
62-
})
63-
profiles := list.GetProfiles()
64-
res := make([]string, len(profiles))
65-
for i, p := range list.GetProfiles() {
66-
res[i] = p.GetName()
61+
sk, err := sketch.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath})
62+
if err != nil {
63+
return nil
6764
}
68-
return res
65+
profiles := sk.GetProfiles()
66+
return f.Map(profiles, (*rpc.SketchProfile).GetName)
6967
}

0 commit comments

Comments
 (0)