Skip to content

Commit fd4f7fb

Browse files
committed
Added PackageManager.GetTool method to find tools
1 parent 5115223 commit fd4f7fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

arduino/cores/packagemanager/package_manager.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,21 @@ func (pm *PackageManager) InstalledBoards() []*cores.Board {
439439
return boards
440440
}
441441

442+
// GetTool search for tool in all packages and platforms.
443+
func (pm *PackageManager) GetTool(toolId string) *cores.Tool {
444+
split := strings.Split(toolId, ":")
445+
if len(split) != 2 {
446+
return nil
447+
}
448+
if pack, ok := pm.Packages[split[0]]; !ok {
449+
return nil
450+
} else if tool, ok := pack.Tools[split[1]]; !ok {
451+
return nil
452+
} else {
453+
return tool
454+
}
455+
}
456+
442457
func (pm *PackageManager) FindToolsRequiredFromPlatformRelease(platform *cores.PlatformRelease) ([]*cores.ToolRelease, error) {
443458
pm.Log.Infof("Searching tools required for platform %s", platform)
444459

0 commit comments

Comments
 (0)