diff --git a/cmd/micro/command.go b/cmd/micro/command.go index 4adb6948..9282d7bd 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -92,7 +92,7 @@ func DefaultCommands() map[string]StrCommand { } } -// InstallPlugin installs the given plugin by exact name match +// PluginCmd installs, removes, updates, lists, or searches for given plugins func PluginCmd(args []string) { if len(args) >= 1 { switch args[0] { @@ -101,8 +101,8 @@ func PluginCmd(args []string) { pp := GetAllPluginPackages().Get(plugin) if pp == nil { messenger.Error("Unknown plugin \"" + plugin + "\"") - } else if !pp.IsInstallable() { - messenger.Error("Plugin \"" + plugin + "\" can not be installed.") + } else if err := pp.IsInstallable(); err != nil { + messenger.Error("Error installing ", plugin, ": ", err) } else { pp.Install() } diff --git a/cmd/micro/pluginmanager.go b/cmd/micro/pluginmanager.go index c2f87b26..6f6be455 100644 --- a/cmd/micro/pluginmanager.go +++ b/cmd/micro/pluginmanager.go @@ -298,13 +298,13 @@ func (pp PluginPackage) Match(text string) bool { } // IsInstallable returns true if the package can be installed. -func (pp PluginPackage) IsInstallable() bool { +func (pp PluginPackage) IsInstallable() error { _, err := GetAllPluginPackages().Resolve(GetInstalledVersions(true), PluginDependencies{ &PluginDependency{ Name: pp.Name, Range: semver.Range(func(v semver.Version) bool { return true }), }}) - return err == nil + return err } // SearchPlugin retrieves a list of all PluginPackages which match the given search text and @@ -320,7 +320,7 @@ pluginLoop: } } - if pp.IsInstallable() { + if err := pp.IsInstallable(); err == nil { plugins = append(plugins, pp) } }