modulepackage
0.1.5
Repository: https://github.com/twinproduction/go-choice.git
Documentation: pkg.go.dev
# README
go-choice
A very simple library for interactively selecting an option on a terminal
Usage
package main
import (
"fmt"
"github.com/TwinProduction/go-choice"
)
func main() {
choice, index, err := gochoice.Pick(
"What do you want to do?\nPick:",
[]string{
"Connect to the production environment",
"Connect to the test environment",
"Update",
},
)
if err != nil {
fmt.Println("You didn't select anything!")
} else {
fmt.Printf("You have selected: '%s', which is the index %d\n", choice, index)
}
}
You can customize the experience further by appending options at the end of the Pick
function:
package main
import (
"fmt"
"github.com/TwinProduction/go-choice"
)
func main() {
choice, index, err := gochoice.Pick(
"What do you want to do?\nPick:",
[]string{
"Connect to the production environment",
"Connect to the test environment",
"Update",
},
gochoice.OptionBackgroundColor(gochoice.Black),
gochoice.OptionTextColor(gochoice.White),
gochoice.OptionSelectedTextColor(gochoice.Red),
gochoice.OptionSelectedTextBold(),
)
if err != nil {
fmt.Println("You didn't select anything!")
} else {
fmt.Printf("You have selected: '%s', which is the index %d\n", choice, index)
}
}
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author