Documentation ¶
Overview ¶
package promptio wraps a test IOStream to make it safe to use the input with promptui.
Example ¶
package main import ( "io" "github.com/hashicorp/hcp/internal/pkg/iostreams" "github.com/hashicorp/hcp/internal/pkg/testing/promptio" "github.com/manifoldco/promptui" ) func main() { // Write to the stream input buffer to simulate interaction with the prompt stream := iostreams.Test() // Write down and then enter _, _ = stream.Input.WriteRune(promptui.KeyNext) _, _ = stream.Input.WriteRune(promptui.KeyEnter) promptIO := promptio.Wrap(stream) prompt := promptui.Select{ Label: "Your prompt", Items: []string{"test", "other"}, Stdin: io.NopCloser(promptIO.In()), } // Run the prompt _, _, _ = prompt.Run() //nolint:dogsled }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.