picker

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package picker asks a person at a terminal: choose one item from a filterable list, confirm, or type a value; it is used only when output.Interactive says a person is there.

Index

Constants

This section is empty.

Variables

View Source
var ErrAborted = errors.New("aborted")

ErrAborted means the person left the question without answering.

View Source
var ErrNoItems = errors.New("nothing to choose from")

ErrNoItems means there was nothing to choose from.

Functions

func Ask

func Ask(in, out *os.File, title, placeholder string, validate func(string) error) (string, error)

Ask asks for a typed value; validate (when not nil) refuses bad input.

func Confirm

func Confirm(in, out *os.File, question string) (bool, error)

Confirm asks a yes or no question; the answer defaults to no.

func ConfirmOrNo

func ConfirmOrNo(in, out *os.File, question string) (bool, error)

ConfirmOrNo asks as Confirm does, with an aborted question answering no.

func Pick

func Pick(in, out *os.File, title string, items []Item) (string, error)

Pick shows the items in a filterable list and returns the chosen slug, or ErrAborted when the person leaves with Esc or Ctrl+C.

Types

type Item

type Item struct{ Slug, Text, Detail string }

Item is one choice: a slug, the text it stands for and optional detail.

Jump to

Keyboard shortcuts

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