prompt

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always

func Always(prompt *Prompt) bool

func AnsweredValueIs

func AnsweredValueIs(prompt *Prompt, key string, value string) bool

func Ask

func Ask(prompt *Prompt, out io.Writer, in io.Reader) error

func BaseOptionValidator

func BaseOptionValidator(p *Prompt, val string) (bool, error)

func CaseInsensitveTextOptionValidator added in v0.1.26

func CaseInsensitveTextOptionValidator(p *Prompt, val string) (bool, error)

Types

type ByText added in v0.1.26

type ByText []Option

func (ByText) Len added in v0.1.26

func (a ByText) Len() int

func (ByText) Less added in v0.1.26

func (a ByText) Less(i int, j int) bool

func (ByText) Swap added in v0.1.26

func (a ByText) Swap(i int, j int)

type FilterFunc added in v0.1.26

type FilterFunc func(prompt *Prompt) bool

type Option

type Option struct {
	// contains filtered or unexported fields
}

func (*Option) String added in v0.1.26

func (o *Option) String() string

String returns the text of the option, which is used for display

func (*Option) Value added in v0.1.26

func (o *Option) Value() string

Value returns the value of the option, which could be an ID or enum value

type Prompt

type Prompt struct {
	// contains filtered or unexported fields
}

func (*Prompt) AddSubPrompt

func (p *Prompt) AddSubPrompt(prompt *Prompt)

func (*Prompt) AvailableOptions

func (p *Prompt) AvailableOptions() []Option

func (*Prompt) DefaultOption added in v0.1.26

func (p *Prompt) DefaultOption() (*Option, bool)

func (*Prompt) DefaultValue added in v0.1.26

func (p *Prompt) DefaultValue() (string, bool)

func (*Prompt) GetAnswer

func (p *Prompt) GetAnswer(key string) string

func (*Prompt) Itr

func (p *Prompt) Itr() func() *Prompt

func (*Prompt) LookupAnswer

func (p *Prompt) LookupAnswer(key string) (string, bool)

func (*Prompt) OptionsToStrings added in v0.1.26

func (p *Prompt) OptionsToStrings() []string

func (*Prompt) Record

func (p *Prompt) Record(answer string) bool

func (*Prompt) String

func (p *Prompt) String() string

func (*Prompt) SubPrompts added in v0.1.26

func (p *Prompt) SubPrompts() []Prompt

func (*Prompt) ValueOf added in v0.1.26

func (p *Prompt) ValueOf(t string) string

ValueOf resolves the value of t, which is assumed to be text, to the value. With options, this is the `value` field of the `Option` with the matching text.

func (*Prompt) VarMap

func (p *Prompt) VarMap() map[string]string

VarMap returns a _copy_ of the variable map

type PromptBuilder

type PromptBuilder struct {
	// contains filtered or unexported fields
}

func NewPromptBuilder

func NewPromptBuilder() *PromptBuilder

func (*PromptBuilder) AddDefaultOption

func (b *PromptBuilder) AddDefaultOption(text string, value string) *PromptBuilder

func (*PromptBuilder) AddOption

func (b *PromptBuilder) AddOption(text string, value string) *PromptBuilder

func (*PromptBuilder) AskWhen

func (b *PromptBuilder) AskWhen(filter FilterFunc) *PromptBuilder

func (*PromptBuilder) Build

func (b *PromptBuilder) Build() (*Prompt, error)

func (*PromptBuilder) Context

func (b *PromptBuilder) Context(ctx *PromptsContext) *PromptBuilder

func (*PromptBuilder) Path

func (b *PromptBuilder) Path(p string) *PromptBuilder

func (*PromptBuilder) Text

func (b *PromptBuilder) Text(t string) *PromptBuilder

func (*PromptBuilder) Textf

func (b *PromptBuilder) Textf(format string, a ...interface{}) *PromptBuilder

func (*PromptBuilder) WithDefault added in v0.1.26

func (b *PromptBuilder) WithDefault(val string) *PromptBuilder

func (*PromptBuilder) WithLogging

func (b *PromptBuilder) WithLogging() *PromptBuilder

func (*PromptBuilder) WithOptions

func (b *PromptBuilder) WithOptions(optionFunc ValueGetter) *PromptBuilder

func (*PromptBuilder) WithValidator

func (b *PromptBuilder) WithValidator(f ValidatorFunc) *PromptBuilder

type PromptsContext

type PromptsContext struct {
	// contains filtered or unexported fields
}

func NewPromptsContext

func NewPromptsContext() *PromptsContext

NewPromptsContext creates a new PromptsContext

func (*PromptsContext) Lookup

func (c *PromptsContext) Lookup(key string) (string, bool)

func (*PromptsContext) Set

func (c *PromptsContext) Set(key string, value string)

Set sets the value of the given key

type ValidatorFunc

type ValidatorFunc func(*Prompt, string) (bool, error)

type ValueGetter

type ValueGetter func() (map[string]string, error)

func ListBasicValues added in v0.1.26

func ListBasicValues(vals []string) ValueGetter

func YesNo

func YesNo() ValueGetter

Jump to

Keyboard shortcuts

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