24 lines
		
	
	
	
		
			449 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			24 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 | ||
|  | } |