cmder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Label      string
	IsSelected bool
}

type PromptResult

type PromptResult struct {
	Type          PromptResultType
	ShouldAskNext bool
	Result        interface{}
	Error         error
}

func (*PromptResult) Ask

func (pr *PromptResult) Ask(question string, validator ValidateFunc) Prompter

func (*PromptResult) AskRepeat

func (pr *PromptResult) AskRepeat(question string, validator ValidateFunc, prompts ...func(result any) Prompter) Prompter

func (*PromptResult) Confirm

func (pr *PromptResult) Confirm(question string, defaultValue rune) Prompter

func (*PromptResult) Fill

func (pr *PromptResult) Fill(ptr any) Prompter

func (*PromptResult) MultiSelect

func (pr *PromptResult) MultiSelect(label string, allItems []*Item, selectedPos int) Prompter

func (*PromptResult) Select

func (pr *PromptResult) Select(label string, items []string) Prompter

func (*PromptResult) When

func (pr *PromptResult) When(cb func(result interface{}) bool, thenPrompt func(prompt Prompter) Prompter) Prompter

type PromptResultType

type PromptResultType int
const (
	PromptResultTypeNormal PromptResultType = iota
	PromptResultTypeBoolean
	PromptResultTypeRecurring
	PromptResultTypeSelect
	PromptResultTypeMultiSelect
)

type Prompter

type Prompter interface {
	Ask(question string, validator ValidateFunc) Prompter
	Confirm(question string, defaultValue rune) Prompter
	AskRepeat(question string, validator ValidateFunc, prompts ...func(result any) Prompter) Prompter
	Select(label string, items []string) Prompter
	MultiSelect(label string, items []*Item, selectedPos int) Prompter
	When(cb func(result interface{}) bool, thenPrompt func(prompt Prompter) Prompter) Prompter
	Fill(ptr any) Prompter
}

func Ask

func Ask(question string, validator ValidateFunc) Prompter

func AskRecurring

func AskRecurring(question string, validator ValidateFunc, prompts ...func(result any) Prompter) Prompter

func Confirm

func Confirm(question string, defaultVal rune) Prompter

func MultiSelect

func MultiSelect(label string, allItems []*Item, selectedPos int) Prompter

MultiSelect() prompts user to select one or more items in the given slice

func Select

func Select(label string, items []string) Prompter

type ValidateFunc

type ValidateFunc func(string) error

Jump to

Keyboard shortcuts

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