Note: This is the documentation for go-box v3.
If your code still importsgithub.com/nyaosorg/go-boxor/v2,
please update the import path togithub.com/nyaosorg/go-box/v3.
box is a command-line program built with the go-box library.
It reads a list of items from STDIN and lets the user select one interactively.
Download the binary package from Releases and extract the executable.
go install github.com/nyaosorg/go-box/v3/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/v3"
)
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")
}
}