fixed
Go to file
Masashi SHIBATA 4b35da6de1
Merge pull request #107 from c-bata/release-v0.2.3
Update CHANGELOG.md to release v0.2.3
2018-10-25 03:16:34 +09:00
.github Update ISSUE_TEMPLATE 2018-06-24 14:28:26 +09:00
_example Update README of examples and tools 2018-10-21 19:04:26 +09:00
_tools Update README of examples and tools 2018-10-21 19:04:26 +09:00
completer Fix FilePathCompleter 2018-06-24 18:14:16 +09:00
.gitignore Initial commit 2017-07-03 23:36:56 +09:00
CHANGELOG.md Update change log to release v0.2.3 2018-10-25 03:15:32 +09:00
Gopkg.lock Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
Gopkg.toml Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
LICENSE Update LICENSE 2017-07-16 13:51:31 +09:00
Makefile Add some tests 2018-02-15 18:15:32 +09:00
README.md Add godoc badge to README [skip ci] 2018-10-18 17:19:14 +09:00
buffer.go Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
buffer_test.go Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
completion.go Add OptionShowCompletionAtStart option 2018-10-23 19:54:01 +09:00
completion_test.go Fix misspell error 2018-02-19 23:26:28 +09:00
document.go Update CHANGELOG for v0.2.2 release. (#84) 2018-06-28 22:06:28 +09:00
document_test.go Add comment about test failure on iTerm2 2018-10-23 19:32:00 +09:00
emacs.go Fix a bug when using OptionWriter 2018-10-20 13:14:56 +09:00
emacs_test.go Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
filter.go Add refactor changes of fuzzy filter 2018-10-20 15:50:53 +09:00
filter_test.go Add refactor changes of fuzzy filter 2018-10-20 15:50:53 +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 Refactor project structure 2018-06-21 02:27:27 +09:00
input_posix.go use fresh /dev/tty fd for stdin in input parser 2018-08-12 21:36:13 +00:00
input_posix_test.go Rename files 2018-06-21 00:55:53 +09:00
input_windows.go Refactor project structure 2018-06-21 02:27:27 +09:00
key.go Fix a godoc description 2018-02-16 14:48:01 +09:00
key_bind.go add ascii-code-bind-option-and-find-current-word-end 2018-04-11 20:14:38 +08:00
key_bind_func.go Update CHANGELOG for v0.2.2 release. (#84) 2018-06-28 22:06:28 +09:00
key_string.go Update key_stringer.go by latest stringer to fix lint errors 2018-02-14 13:22:22 +09:00
option.go Add OptionShowCompletionAtStart option 2018-10-23 19:54:01 +09:00
output.go Fix golint 2018-10-20 13:49:52 +09:00
output_posix.go Add NewStderrWriter (#102) 2018-10-23 12:13:07 +09:00
output_vt100.go Fix resetting attributes for arch linux 2018-10-20 14:28:43 +09:00
output_vt100_test.go Separate VT100 writer 2018-06-21 01:34:12 +09:00
output_windows.go Add NewStderrWriter (#102) 2018-10-23 12:13:07 +09:00
prompt.go Add OptionShowCompletionAtStart option 2018-10-23 19:54:01 +09:00
render.go Add option to customize insertion points for completions 2018-06-24 04:30:07 +09:00
render_test.go Refactor variable names 2017-08-12 18:59:10 +09:00
shortcut.go Refactor project structure 2018-06-21 02:27:27 +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

go-prompt

Go Report Card Software License Backers on Open Collective Sponsors on Open Collective GoDoc

A library for building powerful interactive prompts inspired by python-prompt-toolkit, making it easier to build cross-platform command line tools using Go.

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. Please check option section of GoDoc for more details.

options

Keyboard Shortcuts

Emacs-like keyboard shortcuts are available by default (these also are the default shortcuts in Bash shell). You can customize and expand these shortcuts.

keyboard shortcuts

Key Binding 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 the line before the cursor to the clipboard
Ctrl + L Clear the screen

History

You can use Up arrow and Down arrow to walk through the history of commands executed.

History

Multiple platform support

We have confirmed go-prompt works fine in the following terminals:

  • iTerm2 (macOS)
  • Terminal.app (macOS)
  • Command Prompt (Windows)
  • gnome-terminal (Ubuntu)

Author

Masashi Shibata

Supporting go-prompt

Contributors

This project exists thanks to all the people who contribute.

Backers and Sponsors (OpenCollective)

Started getting support via opencollective. If you support this project by becoming a sponsor, your logo will show up here with a link to your website.

Become a backer

License

This software is licensed under the MIT license, see LICENSE for more information.