list

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = map[string]func() Prompt{
	"":      func() Prompt { return WmenuPrompt{} },
	"wmenu": func() Prompt { return WmenuPrompt{} },
	"fuzzy": func() Prompt { return FuzzyPrompt{} },
}

Types provides a map of prompt types by name

Functions

func WithInputSlice

func WithInputSlice(p Prompt, options, list []string, msg string) (string, error)

WithInputSlice filters options based on a provided slice and then performs a WithInputString prompt

func WithInputString

func WithInputString(p Prompt, options []string, val, msg string) (string, error)

WithInputString returns either the pre-provided selection or the result of a user prompt

Types

type FuzzyPrompt

type FuzzyPrompt struct{}

FuzzyPrompt implements a fuzzy interactive picker

func (FuzzyPrompt) Execute

func (f FuzzyPrompt) Execute(_ string, os OptionSet) (int, error)

Execute runs the list prompt

type Option

type Option struct {
	Name     string
	Metadata map[string]string
}

Option defines a single option for a list prompt

func (Option) String

func (o Option) String() string

String condenses the Name and Metadata into a single flat string

type OptionSet

type OptionSet []Option

OptionSet defines a list of options for a list prompt

type Prompt

type Prompt interface {
	Execute(string, OptionSet) (int, error)
}

Prompt defines an object which can execute list prompts

func Default

func Default() Prompt

Default returns the default Prompt type

type WmenuPrompt

type WmenuPrompt struct{}

WmenuPrompt implements a wmenu-based prompt

func (WmenuPrompt) Execute

func (w WmenuPrompt) Execute(msg string, optSet OptionSet) (int, error)

Execute runs the list prompt

Jump to

Keyboard shortcuts

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