2017-07-05 15:59:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/c-bata/go-prompt-toolkit/prompt"
|
|
|
|
)
|
|
|
|
|
2017-07-15 08:37:54 +00:00
|
|
|
func executor(b *prompt.Buffer) string {
|
|
|
|
r := "\n>>> Your input: '" + b.Text() + "' <<<\n"
|
|
|
|
return r
|
2017-07-14 01:50:35 +00:00
|
|
|
}
|
|
|
|
|
2017-07-15 08:37:54 +00:00
|
|
|
func completer(b *prompt.Buffer) []string {
|
2017-07-15 11:22:56 +00:00
|
|
|
if w := b.Document().GetWordBeforeCursor(); w == "" {
|
|
|
|
return []string{}
|
|
|
|
} else {
|
|
|
|
return []string{"select", "from", "insert", "where"}
|
|
|
|
}
|
2017-07-05 15:59:22 +00:00
|
|
|
}
|
2017-07-14 01:51:19 +00:00
|
|
|
|
2017-07-15 08:37:54 +00:00
|
|
|
func main() {
|
2017-07-15 09:51:33 +00:00
|
|
|
pt := prompt.NewPrompt(executor, completer)
|
2017-07-15 08:37:54 +00:00
|
|
|
defer fmt.Println("\nGoodbye!")
|
2017-07-15 09:51:33 +00:00
|
|
|
fmt.Print("Hello! This is a example appication using prompt-toolkit.\n\n")
|
2017-07-15 08:37:54 +00:00
|
|
|
pt.Run()
|
2017-07-14 01:51:19 +00:00
|
|
|
}
|