mirror of
https://github.com/zyedidia/micro.git
synced 2024-10-06 08:30:10 +03:00
Add more descriptive error messages for plugin installation failures
Ref #378
This commit is contained in:
parent
76a328a062
commit
d3d35bd9ff
@ -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()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user