box
reads choices from STDIN,- On
box
, the user selects one by cursor (HJKL , C-n & C-p & C-f & C-b) box
outputs chosen one to STDOUT.
Download the binary package from Releases and extract the executable.
go install github.com/nyaosorg/go-box/v2/cmd/box@latest
scoop install https://raw.githubusercontent.com/nyaosorg/go-box/master/box.json
or
scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install box
package main
import (
"os"
"github.com/nyaosorg/go-box/v2"
)
func main() {
println("Are you sure ?")
choose, err := box.SelectString([]string{"Yes", "No"}, false, os.Stderr)
if err != nil {
println(err.Error())
os.Exit(1)
}
println()
if len(choose) >= 1 {
println("You selected ->", choose[0])
} else {
println("You did not select any items")
}
}