go-prompt/README.md

86 lines
2.4 KiB
Markdown
Raw Normal View History

2017-08-07 15:19:51 +00:00
# go-prompt
2017-07-03 14:36:56 +00:00
2017-08-12 14:43:35 +00:00
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.
2017-07-03 14:36:56 +00:00
2017-07-17 13:32:13 +00:00
#### Similar Projects
2017-08-12 14:43:35 +00:00
* [jonathanslenders/python-prompt-toolkit](https://github.com/jonathanslenders/python-prompt-toolkit): go-prompt is inspired by this library.
2017-07-17 13:32:13 +00:00
* [peterh/liner](https://github.com/peterh/liner): The most similar project in golang is **liner** that I've ever seen.
2017-08-07 15:19:51 +00:00
#### Projects using go-prompt
2017-07-17 13:32:13 +00:00
2017-08-07 15:19:51 +00:00
* [kube-prompt : An interactive kubernetes client featuring auto-complete written in Go.](https://github.com/c-bata/kube-prompt)
2017-07-16 18:41:00 +00:00
2017-08-12 14:43:35 +00:00
## Features
#### Powerful auto completion
![demo](./_resources/kube-prompt.gif)
(This is a GIF animation of kube-prompt.)
#### Keyboard Shortcuts
![Keyboard shortcuts](./_resources/keyboard-shortcuts.gif)
2017-08-13 04:09:45 +00:00
You can customize keyboard shortcuts. More details are available from 'KeyBoard Shortcuts' section in Developer Guide.
2017-08-12 14:43:35 +00:00
#### Easy to use
Usage is like this:
2017-07-16 18:41:00 +00:00
```go
package main
import (
2017-08-07 15:19:51 +00:00
"fmt"
"github.com/c-bata/go-prompt"
2017-07-16 18:41:00 +00:00
)
2017-08-12 14:43:35 +00:00
func completer(buf prompt.Buffer) []prompt.Suggest {
2017-08-07 15:19:51 +00:00
s := []prompt.Suggest{
{Text: "users", Description: "user table"},
{Text: "sites", Description: "sites table"},
{Text: "articles", Description: "articles table"},
}
2017-08-12 14:43:35 +00:00
return prompt.FilterHasPrefix(s, buf.Text(), true)
2017-07-16 18:41:00 +00:00
}
func main() {
2017-08-12 14:43:35 +00:00
fmt.Println("Please select table.")
t := prompt.Input("> ", completer)
fmt.Println("You selected " + t)
2017-07-16 18:41:00 +00:00
}
```
2017-08-12 14:43:35 +00:00
More practical example is avairable from `_example` directory or [kube-prompt](https://github.com/c-bata/kube-prompt).
2017-07-03 14:36:56 +00:00
2017-08-13 04:09:45 +00:00
#### Flexible customization
2017-07-16 17:58:51 +00:00
![options](./_resources/prompt-options.png)
2017-08-12 14:43:35 +00:00
go-prompt has many color options. All options are listed in [Developer Guide](./example/README.md).
2017-07-16 17:58:51 +00:00
2017-08-12 14:43:35 +00:00
#### History
**up-arrow** and **down-arrow** to walk through the command line history.
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
![History](./_resources/history.gif)
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
## Other Information
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
* If you want to create projects using go-prompt, you might want to look at the [Getting Started](./example/README.md).
* If you want to contribute go-prompt, you might want to look at the [Developer Guide](./_tools/README.md).
2017-08-13 04:09:45 +00:00
* If you want to know internal API, you might want to look at the [GoDoc](http://godoc.org/github.com/c-bata/go-prompt).
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
## Author
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
Masashi Shibata
2017-08-09 03:50:16 +00:00
2017-08-12 14:43:35 +00:00
* Twitter: [@c\_bata\_](https://twitter.com/c_bata_/)
* Github: [@c-bata](https://github.com/c-bata/)
2017-08-09 03:50:16 +00:00
## LICENSE
This software is licensed under the MIT License (See [LICENSE](./LICENSE) ).