prompts

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowAllStringValidator

func AllowAllStringValidator(_ string) error

AllowAllStringValidator is a string validator that allows any string

func GetInputFromPrompt

func GetInputFromPrompt(desiredInput string) string

func GetVariableDefaultValue

func GetVariableDefaultValue(draftConfig *config.DraftConfig, variable *config.BuilderVar) string

GetVariableDefaultValue returns the default value for a variable, if one is set in variableDefaults from a ReferenceVar or literal Variable.DefaultValue in that order.

func NoBlankStringValidator

func NoBlankStringValidator(s string) error

NoBlankStringValidator is a string validator that does not allow blank strings

func RunBoolPrompt

func RunBoolPrompt(customPrompt *config.BuilderVar, Stdin io.ReadCloser, Stdout io.WriteCloser) (string, error)

func RunDefaultableStringPrompt

func RunDefaultableStringPrompt(defaultValue string, customPrompt *config.BuilderVar, validate func(string) error, Stdin io.ReadCloser, Stdout io.WriteCloser) (string, error)

RunDefaultableStringPrompt runs a prompt for a string variable, returning the user string input for the prompt

func RunPromptsFromConfig

func RunPromptsFromConfig(draftConfig *config.DraftConfig) error

func RunPromptsFromConfigWithSkips

func RunPromptsFromConfigWithSkips(draftConfig *config.DraftConfig) error

func RunPromptsFromConfigWithSkipsIO

func RunPromptsFromConfigWithSkipsIO(draftConfig *config.DraftConfig, Stdin io.ReadCloser, Stdout io.WriteCloser) error

RunPromptsFromConfigWithSkipsIO runs the prompts for the given draftConfig skipping any variables in varsToSkip or where the BuilderVar.IsPromptDisabled is true. If Stdin or Stdout are nil, the default values will be used.

func Select

func Select[T any](label string, items []T, opt *SelectOpt[T]) (T, error)

Types

type SelectOpt

type SelectOpt[T any] struct {
	// Field returns the name to use for each select item.
	Field func(t T) string
	// Default is the default selection. If Field is used this should be the result of calling Field on the default.
	Default *T
}

Jump to

Keyboard shortcuts

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