在 Go 中构建强大的交互式提示符,灵感来自 Python-prompt-toolkit。
一个用于构建强大交互式提示的库,灵感来自 Python-prompt-toolkit, 让使用 Go 构建跨平台命令行工具变得更加容易。
package main
import (
"fmt"
"github.com/c-bata/go-prompt"
)
func completer(d prompt.Document) []prompt.Suggest {
s := []prompt.Suggest{
{Text: "users", Description: "Store the username and age"},
{Text: "articles", Description: "Store the article text posted by user"},
{Text: "comments", Description: "Store the text commented to articles"},
}
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
}
func main() {
fmt.Println("Please select table.")
t := prompt.Input("> ", completer)
fmt.Println("You selected " + t)
}暂无开放 Issues,或尚未同步最近议题。