prompt

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Confirm

type Confirm struct {
	*survey.Confirm
}

func (*Confirm) Cleanup

func (s *Confirm) Cleanup(interface{}) error

type EventDispatcher

type EventDispatcher interface {
	EventWithLabel(category, action string, label string, dim ...*dimensions.Values)
}

type Input

type Input struct {
	*survey.Input
}

func (*Input) Cleanup

func (i *Input) Cleanup(val interface{}) error

type Password

type Password struct {
	*survey.Password
}

func (*Password) Cleanup

func (i *Password) Cleanup(val interface{}) error

type Prompt

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

Prompt is our main prompting struct

func (*Prompt) Confirm

func (p *Prompt) Confirm(title, message string, defaultChoice *bool) (bool, error)

Confirm prompts user for yes or no response.

func (*Prompt) Input

func (p *Prompt) Input(title, message string, defaultResponse *string, flags ...ValidatorFlag) (string, error)

Input prompts the user for input. The user can specify available validation flags to trigger validation of responses

func (*Prompt) InputAndValidate

func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string, validator ValidatorFunc, flags ...ValidatorFlag) (string, error)

InputAndValidate prompts an input field and allows you to specfiy a custom validation function as well as the built in flags

func (*Prompt) InputSecret

func (p *Prompt) InputSecret(title, message string, flags ...ValidatorFlag) (string, error)

InputSecret prompts the user for input and obfuscates the text in stdout. Will fail if empty.

func (*Prompt) IsInteractive

func (p *Prompt) IsInteractive() bool

IsInteractive checks if the prompts can be interactive or should just return default values

func (*Prompt) Select

func (p *Prompt) Select(title, message string, choices []string, defaultChoice *string) (string, error)

Select prompts the user to select one entry from multiple choices

type Prompter

type Prompter interface {
	Input(title, message string, defaultResponse *string, flags ...ValidatorFlag) (string, error)
	InputAndValidate(title, message string, defaultResponse *string, validator ValidatorFunc, flags ...ValidatorFlag) (string, error)
	Select(title, message string, choices []string, defaultResponse *string) (string, error)
	Confirm(title, message string, defaultChoice *bool) (bool, error)
	InputSecret(title, message string, flags ...ValidatorFlag) (string, error)
	IsInteractive() bool
}

Prompter is the interface used to run our prompt from, useful for mocking in tests

func New

func New(isInteractive bool, an EventDispatcher) Prompter

New creates a new prompter

type Select

type Select struct {
	*survey.Select
}

func (*Select) Cleanup

func (s *Select) Cleanup(interface{}) error

type ValidatorFlag

type ValidatorFlag int

ValidatorFlag represents flags for prompt functions to change their behavior on.

const (
	// InputRequired requires that the user provide input
	InputRequired ValidatorFlag = iota
)

type ValidatorFunc

type ValidatorFunc = survey.Validator

ValidatorFunc is a function pass to the Prompter to perform validation on the users input

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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