🐛 Fail gracefully when none found
This commit is contained in:
parent
5881f3d538
commit
7a198a0273
7 changed files with 37 additions and 8 deletions
26
io/boolean/boolean.go
Normal file
26
io/boolean/boolean.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue