fixed
Go to file
kayos@tcp.direct 79a61d5a3b
Fix: again
2022-07-08 05:59:21 -07:00
.github Use go 1.16 2021-03-02 02:56:59 +09:00
_example Fix: again 2022-07-08 05:59:21 -07:00
_tools fix path 2022-02-17 04:00:55 -08:00
completer fix path 2022-02-17 04:00:55 -08:00
internal Fix: again 2022-07-08 05:59:21 -07:00
.gitignore Integrate with Travis CI (#103) 2018-10-25 22:59:47 +09:00
CHANGELOG.md fix go mod 2021-07-11 18:51:19 -07:00
LICENSE Update LICENSE 2017-07-16 13:51:31 +09:00
Makefile Remove travis-ci config 2020-09-19 00:06:03 +09:00
README.md fix go mod 2021-07-11 18:51:19 -07:00
buffer.go fix path 2022-02-17 04:00:55 -08:00
buffer_test.go Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
completion.go fix path 2022-02-17 04:00:55 -08:00
completion_test.go Fix misspell error 2018-02-19 23:26:28 +09:00
document.go fix path 2022-02-17 04:00:55 -08:00
document_test.go fix path 2022-02-17 04:00:55 -08:00
emacs.go fix path 2022-02-17 04:00:55 -08:00
emacs_test.go Support CJK and Cyrillic characters 2018-06-22 01:11:58 +09:00
filter.go Fix golint-cli -fast warnings 2020-02-24 14:13:36 +01:00
filter_test.go Add refactor changes of fuzzy filter 2018-10-20 15:50:53 +09:00
go.mod Update deps && Fix breaking changes 2022-06-14 21:44:49 -07:00
go.sum Update deps && Fix breaking changes 2022-06-14 21:44:49 -07: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 input parser 2018-12-18 03:13:07 +09:00
input_posix.go fix path 2022-02-17 04:00:55 -08:00
input_test.go Refactor input parser 2018-12-18 03:13:07 +09:00
input_windows.go Refactor input parser 2018-12-18 03:13:07 +09:00
key.go Use go generate 2018-12-14 22:34:13 +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 Merge pull request #158 from UiP9AV6Y/feature-initial-text 2020-02-28 12:19:16 +09:00
output.go Fix golint 2018-10-20 13:49:52 +09:00
output_posix.go Add debug logger and assert 2018-12-10 04:16:49 +09:00
output_vt100.go fix path 2022-02-17 04:00:55 -08:00
output_vt100_test.go Separate VT100 writer 2018-06-21 01:34:12 +09:00
output_windows.go Fix golint-cli -fast warnings 2020-02-24 14:13:36 +01:00
prompt.go fix path 2022-02-17 04:00:55 -08:00
render.go fix path 2022-02-17 04:00:55 -08:00
render_test.go Don't test render on Windows 2020-02-22 20:47:48 +01:00
shortcut.go Fix golint-cli -fast warnings 2020-02-24 14:13:36 +01:00
signal_posix.go fix path 2022-02-17 04:00:55 -08:00
signal_windows.go fix path 2022-02-17 04:00:55 -08:00

go-prompt

Go Report Card Software License GoDoc tests

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"
	"git.tcp.direct/tcp.direct/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

License

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