choose

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 4 Imported by: 4

README

Bash select in Go

Quick and dirty replacement for Bash select just as an experiment. (Go watch the YouTube stream.) Note that select is a keyword in Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPrompt = `#? `

Functions

func From

func From[T any](choices []T) (int, T, error)

From prompts terminal user to pick from one of the choices using the DefaultChooser.

Types

type Choices

type Choices[T any] []T

func (Choices[T]) Choose

func (c Choices[T]) Choose() (int, T, error)

Choose prompts terminal user to pick from one of the choices and returns the index of the choice with the choice or an empty value and error.

type Chooser

type Chooser[T any] interface {
	Choose() (T, error)
}

Directories

Path Synopsis
cmd
choose command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL