go-prompt/README.md
2017-08-13 13:09:45 +09:00

2.4 KiB

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

Projects using go-prompt

Features

Powerful auto completion

demo

(This is a GIF animation of kube-prompt.)

Keyboard Shortcuts

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

options 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.

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 ).