62d47c3acf | ||
---|---|---|
_example | ||
_tools | ||
.gitignore | ||
LICENSE | ||
Makefile | ||
README.md | ||
bisect.go | ||
buffer.go | ||
buffer_test.go | ||
completion.go | ||
completion_test.go | ||
console_interface.go | ||
document.go | ||
document_test.go | ||
emacs.go | ||
filter.go | ||
filter_test.go | ||
history.go | ||
input.go | ||
key.go | ||
key_bind.go | ||
key_string.go | ||
option.go | ||
prompt.go | ||
render.go | ||
render_test.go | ||
vt100_input.go | ||
vt100_output.go |
go-prompt
Library for building a powerful interactive prompt, inspired by python-prompt-toolkit. Easy building a multi-platform binary of the command line tools because built with Golang.
Similar Projects
- jonathanslenders/python-prompt-toolkit: go-prompt is inspired by this library.
- peterh/liner: The most similar project in golang is liner that I've ever seen.
Projects using go-prompt
Features
Powerful auto completion
(This is a GIF animation of kube-prompt.)
Keyboard Shortcuts
You can customize keyboard shortcuts. More details are available from 'KeyBoard Shortcuts' section in Developer Guide.
Easy to use
Usage is like this:
package main
import (
"fmt"
"github.com/c-bata/go-prompt"
)
func completer(buf prompt.Buffer) []prompt.Suggest {
s := []prompt.Suggest{
{Text: "users", Description: "user table"},
{Text: "sites", Description: "sites table"},
{Text: "articles", Description: "articles table"},
}
return prompt.FilterHasPrefix(s, buf.Text(), true)
}
func main() {
fmt.Println("Please select table.")
t := prompt.Input("> ", completer)
fmt.Println("You selected " + t)
}
More practical example is avairable from _example
directory or kube-prompt.
Flexible customization
go-prompt has many color options. All options are listed in Developer Guide.
History
up-arrow and down-arrow to walk through the command line history.
Other Information
- If you want to create projects using go-prompt, you might want to look at the Getting Started.
- If you want to contribute go-prompt, you might want to look at the Developer Guide.
- If you want to know internal API, you might want to look at the GoDoc.
Author
Masashi Shibata
LICENSE
This software is licensed under the MIT License (See LICENSE ).