autocomplete plugin commands

This commit is contained in:
boombuler
2016-09-28 18:15:39 +02:00
parent 9ea947c808
commit 8aa017bfda
4 changed files with 41 additions and 4 deletions

View File

@@ -149,3 +149,29 @@ func PluginComplete(complete Completion, input string) (chosen string, suggestio
}
return
}
func PluginCmdComplete(input string) (chosen string, suggestions []string) {
for _, cmd := range []string{"install", "remove", "search", "update"} {
if strings.HasPrefix(cmd, input) {
suggestions = append(suggestions, cmd)
}
}
if len(suggestions) == 1 {
chosen = suggestions[0]
}
return chosen, suggestions
}
func PluginNameComplete(input string) (chosen string, suggestions []string) {
for _, pp := range GetAllPluginPackages() {
if strings.HasPrefix(pp.Name, input) {
suggestions = append(suggestions, pp.Name)
}
}
if len(suggestions) == 1 {
chosen = suggestions[0]
}
return chosen, suggestions
}