manifoldco / promptui

Interactive prompt for command-line applications

Home Page:https://www.manifold.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

select captures previous enter key as input

joshuamarquez opened this issue · comments

before select is executed, if enter key is pressed this one will be captured as input for select misleading to undesired behavior.

code to reproduce

package main

import (
	"fmt"
	"time"
	"github.com/manifoldco/promptui"
)

func main() {
	fmt.Println("press 'enter key' to reproduce behaviour")
	time.Sleep(5000 * time.Millisecond)

	prompt := promptui.Select{
		Label: "Select Day",
		Items: []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"},
	}

	_, result, err := prompt.Run()

	if err != nil {
		fmt.Printf("Prompt failed %v\n", err)
		return
	}

	fmt.Printf("You choose %q\n", result)
}

Screen Shot 2021-06-16 at 11 36 09