improved plugin search
This commit is contained in:
parent
8aa017bfda
commit
1fe1c3eabb
2 changed files with 14 additions and 5 deletions
|
@ -119,13 +119,13 @@ func PluginCmd(args []string) {
|
|||
case "update":
|
||||
UpdatePlugins(args[1:])
|
||||
case "search":
|
||||
searchText := strings.Join(args[1:], " ")
|
||||
plugins := SearchPlugin(searchText)
|
||||
plugins := SearchPlugin(args[1:])
|
||||
messenger.Message(len(plugins), " plugins found")
|
||||
for _, p := range plugins {
|
||||
messenger.AddLog("\n")
|
||||
messenger.AddLog("----------------")
|
||||
messenger.AddLog(p.String())
|
||||
}
|
||||
messenger.AddLog("----------------")
|
||||
if len(plugins) > 0 {
|
||||
if CurView().Type != vtLog {
|
||||
ToggleLog([]string{})
|
||||
|
|
|
@ -81,6 +81,7 @@ func (pp *PluginPackage) String() string {
|
|||
buf.WriteRune('\n')
|
||||
}
|
||||
if pp.Description != "" {
|
||||
buf.WriteRune('\n')
|
||||
buf.WriteString(pp.Description)
|
||||
}
|
||||
return buf.String()
|
||||
|
@ -270,10 +271,18 @@ func (pp PluginPackage) IsInstallable() bool {
|
|||
|
||||
// SearchPlugin retrieves a list of all PluginPackages which match the given search text and
|
||||
// could be or are already installed
|
||||
func SearchPlugin(text string) (plugins PluginPackages) {
|
||||
func SearchPlugin(texts []string) (plugins PluginPackages) {
|
||||
plugins = make(PluginPackages, 0)
|
||||
|
||||
pluginLoop:
|
||||
for _, pp := range GetAllPluginPackages() {
|
||||
if pp.Match(text) && pp.IsInstallable() {
|
||||
for _, text := range texts {
|
||||
if !pp.Match(text) {
|
||||
continue pluginLoop
|
||||
}
|
||||
}
|
||||
|
||||
if pp.IsInstallable() {
|
||||
plugins = append(plugins, pp)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue