prompts

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowAllStringValidator added in v0.0.28

func AllowAllStringValidator(_ string) error

AllowAllStringValidator is a string validator that allows any string

func GetInputFromPrompt

func GetInputFromPrompt(desiredInput string) string

func GetVariableDefaultValue added in v0.0.28

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 added in v0.0.28

func NoBlankStringValidator(s string) error

NoBlankStringValidator is a string validator that does not allow blank strings

func RunBoolPrompt added in v0.0.28

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

func RunDefaultableStringPrompt added in v0.0.28

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 added in v0.0.24

func RunPromptsFromConfigWithSkips(draftConfig *config.DraftConfig) error

func RunPromptsFromConfigWithSkipsIO added in v0.0.28

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 added in v0.0.36

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

Types

type SelectOpt added in v0.0.36

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