choose

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package choose provides an interface to choose one option from a given list of options. The options can be provided as (new-line separated) stdin or a list of arguments.

It is different from the filter command as it does not provide a fuzzy finding input, so it is best used for smaller lists of options.

Let's pick from a list of gum flavors:

$ gum choose "Strawberry" "Banana" "Cherry"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Options []string `arg:"" optional:"" help:"Options to choose from."`

	Limit             int          `help:"Maximum number of options to pick" default:"1" group:"Selection"`
	NoLimit           bool         `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
	Height            int          `help:"Height of the list" default:"10" env:"GUM_CHOOSE_HEIGHT"`
	Cursor            string       `help:"Prefix to show on item that corresponds to the cursor position" default:"> " env:"GUM_CHOOSE_CURSOR"`
	CursorPrefix      string       `help:"Prefix to show on the cursor item (hidden if limit is 1)" default:"[•] " env:"GUM_CHOOSE_CURSOR_PREFIX"`
	SelectedPrefix    string       `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[✕] " env:"GUM_CHOOSE_SELECTED_PREFIX"`
	UnselectedPrefix  string       `help:"Prefix to show on selected items (hidden if limit is 1)" default:"[ ] " env:"GUM_CHOOSE_UNSELECTED_PREFIX"`
	CursorStyle       style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_CURSOR_"`
	ItemStyle         style.Styles `embed:"" prefix:"item." hidden:"" envprefix:"GUM_CHOOSE_ITEM_"`
	SelectedItemStyle style.Styles `embed:"" prefix:"selected." set:"defaultForeground=212" envprefix:"GUM_CHOOSE_SELECTED_"`
}

Options is the customization options for the choose command.

func (Options) BeforeReset

func (o Options) BeforeReset(ctx *kong.Context) error

BeforeReset hook. Used to unclutter style flags.

func (Options) Run

func (o Options) Run() error

Run provides a shell script interface for choosing between different through options.

Jump to

Keyboard shortcuts

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