mirror of https://github.com/pulumi/pulumi.git
b51caa6ab4
Switch the cmdutil.ReadConsole and cmdutil.ReadConsoleNoEcho functions to use the bubbletea library to render the prompt, using the textinput widget provided by the accompanying bubbles library. The resulting input widgets support arrow keys, back space, and some basic readline-style bindings including Ctrl-A, Alt-B, etc. I went through all uses of ReadConsole or ReadConsoleNoEcho. Only the one in new.go had a non-compliant prompt that I had to adjust. Note: One divergence in behavior I opted for was that password prompts will echo '*' characters as the user is typing and then no echo once they've accepted or canceled the value. Previously, the prompt did not echo anything in either case. <details> <summary> Introduction if you're unfamiliar with bubbletea </summary> bubbletea operates by modeling the widget state as an immutable data structure that receives messages for events. On receiving a message (key press, e.g.) the model's Update method returns a new model instance representing its new state. Update may also optionally return additional commands for the program, e.g. stop running, or print something and move on. The model's View method returns what should be drawn in the terminal based on the model's current state. This programming model makes it reasonably straightforward to unit test some of the core functionality of independent widgets as demonstrated in this PR. </details> Resolves #1565 --- Demos: <details> <summary>Plain text</summary> ![prompt-plain](https://github.com/pulumi/pulumi/assets/41730/66258fc8-f772-4d01-bc7c-1f7b116aebaa) </details> <details> <summary>Secret</summary> ![prompt-secret](https://github.com/pulumi/pulumi/assets/41730/372f862e-9186-4d47-ba7d-0107c47f52f6) </details> <details> <summary>Secret prompt with padding</summary> ![prompt-secret-2](https://github.com/pulumi/pulumi/assets/41730/e9b7c253-4c9d-4235-9fa6-197aa0522033) </details> |
||
---|---|---|
.. | ||
go | ||
testcomponent-go |