Skip to content

Commit

Permalink
apply changes to search vidpid
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Oct 10, 2023
1 parent 3703157 commit 4f7fc98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions arduino/cores/packagemanager/package_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func (pme *Explorer) GetCustomGlobalProperties() *properties.Map {
}

// FindPlatformReleaseProvidingBoardsWithVidPid FIXMEDOC
func (pme *Explorer) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid string) []*cores.PlatformRelease {
res := []*cores.PlatformRelease{}
func (pme *Explorer) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid string) []*cores.Platform {
res := []*cores.Platform{}
for _, targetPackage := range pme.packages {
for _, targetPlatform := range targetPackage.Platforms {
platformRelease := targetPlatform.GetLatestRelease()
Expand All @@ -202,7 +202,7 @@ func (pme *Explorer) FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid strin
}
for _, boardManifest := range platformRelease.BoardsManifest {
if boardManifest.HasUsbID(vid, pid) {
res = append(res, platformRelease)
res = append(res, targetPlatform)
break
}
}
Expand Down
7 changes: 1 addition & 6 deletions commands/core/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/arduino/utils"
"github.com/arduino/arduino-cli/commands"
f "github.com/arduino/arduino-cli/internal/algorithms"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
)

Expand All @@ -39,11 +38,7 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
res := []*cores.Platform{}
if isUsb, _ := regexp.MatchString("[0-9a-f]{4}:[0-9a-f]{4}", req.SearchArgs); isUsb {
vid, pid := req.SearchArgs[:4], req.SearchArgs[5:]
// TODO: De-duplicate return Platforms
// TODO: Inline FindPlatformReleaseProvidingBoardsWithVidPid
res = f.Map(pme.FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid), func(x *cores.PlatformRelease) *cores.Platform {
return x.Platform
})
res = pme.FindPlatformReleaseProvidingBoardsWithVidPid(vid, pid)
} else {
searchArgs := utils.SearchTermsFromQueryString(req.SearchArgs)
for _, targetPackage := range pme.GetPackages() {
Expand Down

0 comments on commit 4f7fc98

Please sign in to comment.