|
1 | | -# go-prompt |
2 | | - |
3 | | -[](https://goreportcard.com/report/github.com/c-bata/go-prompt) |
4 | | - |
5 | | -[](https://godoc.org/github.com/c-bata/go-prompt) |
6 | | - |
7 | | - |
8 | | -A library for building powerful interactive prompts inspired by [python-prompt-toolkit](https://github.com/jonathanslenders/python-prompt-toolkit), |
9 | | -making it easier to build cross-platform command line tools using Go. |
10 | | - |
11 | | -```go |
12 | | -package main |
13 | | - |
14 | | -import ( |
15 | | - "fmt" |
16 | | - "github.com/c-bata/go-prompt" |
17 | | -) |
18 | | - |
19 | | -func completer(d prompt.Document) []prompt.Suggest { |
20 | | - s := []prompt.Suggest{ |
21 | | - {Text: "users", Description: "Store the username and age"}, |
22 | | - {Text: "articles", Description: "Store the article text posted by user"}, |
23 | | - {Text: "comments", Description: "Store the text commented to articles"}, |
24 | | - } |
25 | | - return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true) |
26 | | -} |
27 | | - |
28 | | -func main() { |
29 | | - fmt.Println("Please select table.") |
30 | | - t := prompt.Input("> ", completer) |
31 | | - fmt.Println("You selected " + t) |
32 | | -} |
33 | | -``` |
34 | | - |
35 | | -#### Projects using go-prompt |
36 | | - |
37 | | -* [c-bata/kube-prompt : An interactive kubernetes client featuring auto-complete written in Go.](https://github.com/c-bata/kube-prompt) |
38 | | -* [rancher/cli : The Rancher Command Line Interface (CLI)is a unified tool to manage your Rancher server](https://github.com/rancher/cli) |
39 | | -* [kubicorn/kubicorn : Simple, cloud native infrastructure for Kubernetes.](https://github.com/kubicorn/kubicorn) |
40 | | -* [cch123/asm-cli : Interactive shell of assembly language(X86/X64) based on unicorn and rasm2](https://github.com/cch123/asm-cli) |
41 | | -* [ktr0731/evans : more expressive universal gRPC client](https://github.com/ktr0731/evans) |
42 | | -* [CrushedPixel/moshpit: A Command-line tool for datamoshing.](https://github.com/CrushedPixel/moshpit) |
43 | | -* [last-ent/testy-go: Testy Go: A tool for easy testing!](https://github.com/last-ent/testy-go) |
44 | | -* [tiagorlampert/CHAOS: a PoC that allow generate payloads and control remote operating systems.](https://github.com/tiagorlampert/CHAOS) |
45 | | -* [abs-lang/abs: ABS is a scripting language that works best on terminal. It tries to combine the elegance of languages such as Python, or Ruby, to the convenience of Bash.](https://github.com/abs-lang/abs) |
46 | | -* [takashabe/btcli: btcli is a CLI client for the Bigtable. Has many read options and auto-completion.](https://github.com/takashabe/btcli) |
47 | | -* [ysn2233/kafka-prompt: An interactive kafka-prompt(kafka-shell) built on existing kafka command client](https://github.com/ysn2233/kafka-prompt) |
48 | | -* [fishi0x01/vsh: HashiCorp Vault interactive shell](https://github.com/fishi0x01/vsh) |
49 | | -* [mstrYoda/docker-shell: A simple interactive prompt for docker](https://github.com/mstrYoda/docker-shell) |
50 | | -* [c-bata/gh-prompt: An interactive GitHub CLI featuring auto-complete.](https://github.com/c-bata/gh-prompt) |
51 | | -* [docker-slim/docker-slim: Don't change anything in your Docker container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)](https://github.com/docker-slim/docker-slim) |
52 | | -* [rueyaa332266/ezcron: Ezcron is a CLI tool, helping you deal with cron expression easier.](https://github.com/rueyaa332266/ezcron) |
53 | | -* [qingstor/qsctl: Advanced command line tool for QingStor Object Storage.](https://github.com/qingstor/qsctl) |
54 | | -* [segmentio/topicctl: Tool for declarative management of Kafka topics](https://github.com/segmentio/topicctl) |
55 | | -* [chriswalz/bit: Bit is a modern Git CLI](https://github.com/chriswalz/bit) |
56 | | -* (If you create a CLI utility using go-prompt and want your own project to be listed here, please submit a GitHub issue.) |
57 | | - |
58 | | -## Features |
59 | | - |
60 | | -### Powerful auto-completion |
61 | | - |
62 | | -[](https://github.com/c-bata/kube-prompt) |
63 | | - |
64 | | -(This is a GIF animation of kube-prompt.) |
65 | | - |
66 | | -### Flexible options |
67 | | - |
68 | | -go-prompt provides many options. Please check [option section of GoDoc](https://godoc.org/github.com/c-bata/go-prompt#Option) for more details. |
69 | | - |
70 | | -[](#flexible-options) |
71 | | - |
72 | | -### Keyboard Shortcuts |
73 | | - |
74 | | -Emacs-like keyboard shortcuts are available by default (these also are the default shortcuts in Bash shell). |
75 | | -You can customize and expand these shortcuts. |
76 | | - |
77 | | -[](#keyboard-shortcuts) |
78 | | - |
79 | | -Key Binding | Description |
80 | | ----------------------|--------------------------------------------------------- |
81 | | -<kbd>Ctrl + A</kbd> | Go to the beginning of the line (Home) |
82 | | -<kbd>Ctrl + E</kbd> | Go to the end of the line (End) |
83 | | -<kbd>Ctrl + P</kbd> | Previous command (Up arrow) |
84 | | -<kbd>Ctrl + N</kbd> | Next command (Down arrow) |
85 | | -<kbd>Ctrl + F</kbd> | Forward one character |
86 | | -<kbd>Ctrl + B</kbd> | Backward one character |
87 | | -<kbd>Ctrl + D</kbd> | Delete character under the cursor |
88 | | -<kbd>Ctrl + H</kbd> | Delete character before the cursor (Backspace) |
89 | | -<kbd>Ctrl + W</kbd> | Cut the word before the cursor to the clipboard |
90 | | -<kbd>Ctrl + K</kbd> | Cut the line after the cursor to the clipboard |
91 | | -<kbd>Ctrl + U</kbd> | Cut the line before the cursor to the clipboard |
92 | | -<kbd>Ctrl + L</kbd> | Clear the screen |
93 | | - |
94 | | -### History |
95 | | - |
96 | | -You can use <kbd>Up arrow</kbd> and <kbd>Down arrow</kbd> to walk through the history of commands executed. |
97 | | - |
98 | | -[](#history) |
99 | | - |
100 | | -### Multiple platform support |
101 | | - |
102 | | -We have confirmed go-prompt works fine in the following terminals: |
103 | | - |
104 | | -* iTerm2 (macOS) |
105 | | -* Terminal.app (macOS) |
106 | | -* Command Prompt (Windows) |
107 | | -* gnome-terminal (Ubuntu) |
108 | | - |
109 | | -## Links |
110 | | - |
111 | | -* [Change Log](./CHANGELOG.md) |
112 | | -* [GoDoc](http://godoc.org/github.com/c-bata/go-prompt) |
113 | | -* [gocover.io](https://gocover.io/github.com/c-bata/go-prompt) |
114 | | - |
115 | | -## Author |
116 | | - |
117 | | -Masashi Shibata |
118 | | - |
119 | | -* Twitter: [@c\_bata\_](https://twitter.com/c_bata_/) |
120 | | -* Github: [@c-bata](https://github.com/c-bata/) |
121 | | - |
122 | | -## License |
123 | | - |
124 | | -This software is licensed under the MIT license, see [LICENSE](./LICENSE) for more information. |
125 | | - |
| 1 | +This is a fork of c-bata/go-prompt optimized for ktr0731/evans. It's not recommended to use this fork for other projects! |
0 commit comments