Add simple yes/no interface

This commit is contained in:
Dan Jones 2023-09-03 22:39:40 -05:00
commit 433f49e9e0
5 changed files with 75 additions and 6 deletions

23
input/boolean/boolean.go Normal file
View file

@ -0,0 +1,23 @@
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
}