fixed
Go to file
c-bata 12250c6c07 Fix some lint errors 2018-02-14 01:14:22 +09:00
_example Run goimports 2018-02-13 23:42:52 +09:00
_tools Add some refactor changes 2018-02-12 19:36:21 +09:00
.gitignore Initial commit 2017-07-03 23:36:56 +09:00
CHANGELOG.md Add change log for v0.2.0 2018-02-13 23:43:51 +09:00
DEVELOPER_GUIDE.md Update some options for pagination 2018-02-13 23:50:24 +09:00
LICENSE Update LICENSE 2017-07-16 13:51:31 +09:00
Makefile Add command to check the race condition 2017-10-08 20:58:09 +09:00
README.md Add evans: gRPC client 2018-02-04 12:52:19 +09:00
bisect.go Add tests for bisect 2017-08-15 01:50:21 +09:00
bisect_test.go Fix some lint error 2017-08-16 13:39:59 +09:00
buffer.go Replace panic to log.Print 2017-08-06 15:21:14 +09:00
buffer_test.go Move go files to project root 2017-07-18 05:27:57 +09:00
completion.go Fix some lint errors 2018-02-14 01:14:22 +09:00
completion_test.go Run fmt 2017-08-15 01:50:04 +09:00
console_interface.go Fix some lint errors 2018-02-14 01:14:22 +09:00
document.go Imitate general ControlW behavior 2017-08-16 18:26:56 +09:00
document_test.go Merge pull request #3 from hori-ryota/feature/fix-some-linterr 2017-08-16 18:31:44 +09:00
emacs.go Add some refactor changes 2018-02-12 19:36:21 +09:00
emacs_test.go Refactor emacs keybind 2017-08-15 01:50:33 +09:00
filter.go Add a comment to some exported functions 2017-08-18 01:40:41 +09:00
filter_test.go Add prompt.Input and prompt.Choose 2017-08-10 01:06:42 +09:00
history.go Fix some lint errors 2018-02-14 01:14:22 +09:00
history_test.go Refactor tests for history 2017-10-11 12:01:40 +09:00
input.go Fix Input and Choose 2017-08-18 02:12:13 +09:00
key.go Add some doc comments 2017-08-22 00:47:15 +09:00
key_bind.go Refactor emacs keybind 2017-08-15 01:50:33 +09:00
key_string.go Move go files to project root 2017-07-18 05:27:57 +09:00
option.go Update some options for pagination 2018-02-13 23:50:24 +09:00
posix_input.go Fix some lint errors 2018-02-14 01:14:22 +09:00
posix_output.go Add some refactor changes 2018-02-12 19:36:21 +09:00
prompt.go Change filepath for debug log for supporting multiple platfroms (#33) 2018-02-13 00:04:49 +09:00
render.go Fix some lint errors 2018-02-14 01:14:22 +09:00
render_test.go Refactor variable names 2017-08-12 18:59:10 +09:00
signal_posix.go windows support 2018-02-12 19:20:57 +09:00
signal_windows.go Add hundling to stopHandleSignalCh 2018-02-12 19:20:57 +09:00
windows_input.go Fix some lint errors 2018-02-14 01:14:22 +09:00
windows_output.go Add some refactor changes 2018-02-12 19:36:21 +09:00

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 written in Golang.

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"},
	}
	return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
}

func main() {
	fmt.Println("Please select table.")
	t := prompt.Input("> ", completer)
	fmt.Println("You selected " + t)
}

Projects using go-prompt

Features

Powerful auto-completion

demo

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

Flexible options

go-prompt provides many options. All options are listed in Developer Guide.

options

Keyboard Shortcuts

Emacs-like keyboard shortcut is available by default (it's also default shortcuts in Bash shell). You can customize and expand these shortcuts.

keyboard shortcuts

KeyBinding Description
Ctrl + A Go to the beginning of the line (Home)
Ctrl + E Go to the End of the line (End)
Ctrl + P Previous command (Up arrow)
Ctrl + N Next command (Down arrow)
Ctrl + F Forward one character
Ctrl + B Backward one character
Ctrl + D Delete character under the cursor
Ctrl + H Delete character before the cursor (Backspace)
Ctrl + W Cut the Word before the cursor to the clipboard.
Ctrl + K Cut the Line after the cursor to the clipboard.
Ctrl + U Cut/delete the Line before the cursor to the clipboard.

History

You can use up-arrow and down-arrow to walk through the history of commands executed.

History

Author

Masashi Shibata

LICENSE

This software is licensed under the MIT License (See LICENSE ).