переход на bubble tea библиотеку
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
// Package suggestions
|
||||
package suggestions
|
||||
|
||||
import "github.com/c-bata/go-prompt"
|
||||
import "strings"
|
||||
|
||||
var defaultSuggestions = []prompt.Suggest{
|
||||
{Text: "exit", Description: "Exit from shell"},
|
||||
}
|
||||
var defaultSuggestions = []string{"exit"}
|
||||
|
||||
func Completer(d prompt.Document) []prompt.Suggest {
|
||||
// Если пользователь уже начал что-то писать, фильтруем список
|
||||
return prompt.FilterHasPrefix(defaultSuggestions, d.GetWordBeforeCursor(), true)
|
||||
func Completer(in string) []string {
|
||||
if in=="" {return nil}
|
||||
var matched []string
|
||||
for _,cmd := range defaultSuggestions {
|
||||
if strings.HasPrefix(cmd,in){
|
||||
matched=append(matched, cmd)
|
||||
}
|
||||
}
|
||||
return matched
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user