fixed
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kayos a962cc8abe fix go mod 5 months ago
.github Use go 1.16 9 months ago
_example fix go mod 5 months ago
_tools fix go mod 5 months ago
completer fix go mod 5 months ago
internal fix go mod 5 months ago
.gitignore Integrate with Travis CI (#103) 3 years ago
CHANGELOG.md fix go mod 5 months ago
LICENSE Update LICENSE 4 years ago
Makefile Remove travis-ci config 1 year ago
README.md fix go mod 5 months ago
buffer.go fix go mod 5 months ago
buffer_test.go Support CJK and Cyrillic characters 4 years ago
completion.go fix go mod 5 months ago
completion_test.go Fix misspell error 4 years ago
document.go fix go mod 5 months ago
document_test.go fix go mod 5 months ago
emacs.go fix go mod 5 months ago
emacs_test.go Support CJK and Cyrillic characters 4 years ago
filter.go Fix golint-cli -fast warnings 2 years ago
filter_test.go Add refactor changes of fuzzy filter 3 years ago
go.mod fix go mod 5 months ago
go.sum Update pkg/term to 1.2.0 9 months ago
history.go Fix some lint errors 4 years ago
history_test.go Refactor tests for history 4 years ago
input.go Refactor input parser 3 years ago
input_posix.go fix go mod 5 months ago
input_test.go Refactor input parser 3 years ago
input_windows.go Refactor input parser 3 years ago
key.go Use go generate 3 years ago
key_bind.go add ascii-code-bind-option-and-find-current-word-end 4 years ago
key_bind_func.go Update CHANGELOG for v0.2.2 release. (#84) 3 years ago
key_string.go Update key_stringer.go by latest stringer to fix lint errors 4 years ago
option.go Merge pull request #158 from UiP9AV6Y/feature-initial-text 2 years ago
output.go Fix golint 3 years ago
output_posix.go Add debug logger and assert 3 years ago
output_vt100.go fix go mod 5 months ago
output_vt100_test.go Separate VT100 writer 4 years ago
output_windows.go Fix golint-cli -fast warnings 2 years ago
prompt.go fix go mod 5 months ago
render.go fix go mod 5 months ago
render_test.go Don't test render on Windows 2 years ago
shortcut.go Fix golint-cli -fast warnings 2 years ago
signal_posix.go fix go mod 5 months ago
signal_windows.go fix go mod 5 months ago

README.md

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.