strip-beats/input/boolean/boolean.go

27 lines
480 B
Go
Raw Normal View History

2023-09-03 22:39:40 -05:00
package boolean
import "github.com/rivo/tview"
2023-09-04 15:10:02 -05:00
func Choose(text string) bool {
2023-09-03 22:39:40 -05:00
choice := false
app := tview.NewApplication()
2023-09-04 15:10:02 -05:00
modal := tview.NewModal()
if text != "" {
modal.SetText(text)
}
modal.AddButtons([]string{"Yes", "No"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Yes" {
choice = true
}
2023-09-03 22:39:40 -05:00
app.Stop()
})
2023-09-04 15:10:02 -05:00
if err := app.SetRoot(modal, false).EnableMouse(true).Run(); err != nil {
2023-09-03 22:39:40 -05:00
panic(err)
}
return choice
}