🐛 Fail gracefully when none found

This commit is contained in:
Dan Jones 2023-11-11 18:51:38 -06:00
commit 7a198a0273
7 changed files with 37 additions and 8 deletions

26
io/boolean/boolean.go Normal file
View file

@ -0,0 +1,26 @@
package boolean
import "github.com/rivo/tview"
func Choose(text string) bool {
choice := false
app := tview.NewApplication()
modal := tview.NewModal()
if text != "" {
modal.SetText(text)
}
modal.AddButtons([]string{"Yes", "No"}).
SetDoneFunc(func(buttonIndex int, buttonLabel string) {
if buttonLabel == "Yes" {
choice = true
}
app.Stop()
})
if err := app.SetRoot(modal, false).EnableMouse(true).Run(); err != nil {
panic(err)
}
return choice
}