Skip to content

nyaosorg/go-box

Repository files navigation

Go-Box - Interactive item selector

Go Test License Go Reference

Note: This is the documentation for go-box v3.
If your code still imports github.com/nyaosorg/go-box or /v2,
please update the import path to github.com/nyaosorg/go-box/v3.

box - Executable

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.

demo

Install

Download the binary package from Releases and extract the executable.

Use "go install"

go install github.com/nyaosorg/go-box/v3/cmd/box@latest

Use "scoop-installer"

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

go-box - golang package

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")
    }
}

Release notes