strip-beats/input/boolean/boolean.go
2023-09-03 22:39:40 -05:00

23 lines
449 B
Go

package boolean
import "github.com/rivo/tview"
func Choose(title string) bool {
choice := false
app := tview.NewApplication()
list := tview.NewList().
AddItem("Yes", "", 'y', func() {
choice = true
app.Stop()
}).
AddItem("No", "", 'n', func() {
choice = false
app.Stop()
})
list.Box.SetBorder(true).SetTitle(title)
if err := app.SetRoot(list, false).EnableMouse(true).Run(); err != nil {
panic(err)
}
return choice
}