Last active
April 28, 2022 06:42
-
-
Save AspenJames/970a014033b1adb695b65c9fffe1c428 to your computer and use it in GitHub Desktop.
Reproduce c-bata/go-prompt issue #253
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}, | |
{Text: "exit", Description: "Stop the looping!"}, | |
} | |
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true) | |
} | |
func main() { | |
for { | |
fmt.Println("Please select table.") | |
t := prompt.Input("> ", completer) | |
if t == "exit" { | |
break | |
} | |
fmt.Println("You selected " + t) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment