Commit 6edf0dda authored by Cristian Maglie's avatar Cristian Maglie

Removed dead code experiment for event handler

parent 97bb3912
......@@ -57,17 +57,6 @@ type PackageManager struct {
PackagesDir *paths.Path
DownloadDir *paths.Path
TempDir *paths.Path
// TODO: This might be a list in the future, but would it be of any help?
eventHandler EventHandler
}
// EventHandler defines the events that are generated by the PackageManager
// Subscribing to such events allows, for instance, to print out logs of what is happening
// (say you use them for a CLI...)
type EventHandler interface {
// FIXME: This is temporary, for prototyping (an handler should not return an handler; besides, this leakes
// the usage of releases...)
}
// NewPackageManager returns a new instance of the PackageManager
......@@ -219,21 +208,6 @@ func (pm *PackageManager) ResolveFQBN(fqbn *cores.FQBN) (
return targetPackage, platformRelease, board, buildProperties, buildPlatformRelease, nil
}
// FIXME add an handler to be invoked on each verbose operation, in order to let commands display results through the formatter
// as for the progress bars during download
func (pm *PackageManager) RegisterEventHandler(eventHandler EventHandler) {
if pm.eventHandler != nil {
panic("Don't try to register another event handler to the PackageManager yet!")
}
pm.eventHandler = eventHandler
}
// GetEventHandlers returns a slice of the registered EventHandlers
func (pm *PackageManager) GetEventHandlers() []*EventHandler {
return append([]*EventHandler{}, &pm.eventHandler)
}
// LoadPackageIndex loads a package index by looking up the local cached file from the specified URL
func (pm *PackageManager) LoadPackageIndex(URL *url.URL) error {
indexPath := pm.IndexDir.Join(path.Base(URL.Path))
......
......@@ -94,13 +94,6 @@ func InitPackageManager() *packagemanager.PackageManager {
}
}
// TODO: were should we register the event handler? Multiple places?
if len(pm.GetEventHandlers()) == 0 {
// During tests this could get registered multiple times,
// since there is an underlying singleton
pm.RegisterEventHandler(&CLIPackageManagerEventHandler{})
}
if err := pm.LoadHardware(Config); err != nil {
formatter.PrintError(err, "Error loading hardware packages.")
os.Exit(ErrCoreConfig)
......@@ -183,11 +176,3 @@ func InitSketch(sketchPath *paths.Path) (*sk.Sketch, error) {
logrus.Infof("Reading sketch from dir: %s", wd)
return sketches.NewSketchFromPath(wd)
}
// CLIPackageManagerEventHandler defines an event handler which outputs the PackageManager events
// in the CLI format
type CLIPackageManagerEventHandler struct{}
// Implement packagemanager.EventHandler interface
// END -- Implement packagemanager.EventHandler interface
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment