prompt

package
v1.372.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prompt asks the operator questions on stdin. A prompter can be non-interactive, in which case every question is answered with its default instead of being asked, which is what unattended runs (CI, --yes style flags) use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockPrompter

type MockPrompter struct {
	mock.Mock
}

MockPrompter is an autogenerated mock type for the Prompter type

func NewMockPrompter

func NewMockPrompter(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPrompter

NewMockPrompter creates a new instance of MockPrompter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockPrompter) Bool

func (_mock *MockPrompter) Bool(prompt string, defaultValue bool) bool

Bool provides a mock function for the type MockPrompter

func (*MockPrompter) Choice

func (_mock *MockPrompter) Choice(prompt string, choices []string, defaultValue string) string

Choice provides a mock function for the type MockPrompter

func (*MockPrompter) EXPECT

func (_m *MockPrompter) EXPECT() *MockPrompter_Expecter

func (*MockPrompter) Int

func (_mock *MockPrompter) Int(prompt string, defaultValue int) int

Int provides a mock function for the type MockPrompter

func (*MockPrompter) String

func (_mock *MockPrompter) String(prompt string, defaultValue string) string

String provides a mock function for the type MockPrompter

func (*MockPrompter) StringSlice

func (_mock *MockPrompter) StringSlice(prompt string, defaultValue []string) []string

StringSlice provides a mock function for the type MockPrompter

type MockPrompter_Bool_Call

type MockPrompter_Bool_Call struct {
	*mock.Call
}

MockPrompter_Bool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bool'

func (*MockPrompter_Bool_Call) Return

func (*MockPrompter_Bool_Call) Run

func (_c *MockPrompter_Bool_Call) Run(run func(prompt string, defaultValue bool)) *MockPrompter_Bool_Call

func (*MockPrompter_Bool_Call) RunAndReturn

func (_c *MockPrompter_Bool_Call) RunAndReturn(run func(prompt string, defaultValue bool) bool) *MockPrompter_Bool_Call

type MockPrompter_Choice_Call

type MockPrompter_Choice_Call struct {
	*mock.Call
}

MockPrompter_Choice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Choice'

func (*MockPrompter_Choice_Call) Return

func (*MockPrompter_Choice_Call) Run

func (_c *MockPrompter_Choice_Call) Run(run func(prompt string, choices []string, defaultValue string)) *MockPrompter_Choice_Call

func (*MockPrompter_Choice_Call) RunAndReturn

func (_c *MockPrompter_Choice_Call) RunAndReturn(run func(prompt string, choices []string, defaultValue string) string) *MockPrompter_Choice_Call

type MockPrompter_Expecter

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

func (*MockPrompter_Expecter) Bool

func (_e *MockPrompter_Expecter) Bool(prompt any, defaultValue any) *MockPrompter_Bool_Call

Bool is a helper method to define mock.On call

  • prompt string
  • defaultValue bool

func (*MockPrompter_Expecter) Choice

func (_e *MockPrompter_Expecter) Choice(prompt any, choices any, defaultValue any) *MockPrompter_Choice_Call

Choice is a helper method to define mock.On call

  • prompt string
  • choices []string
  • defaultValue string

func (*MockPrompter_Expecter) Int

func (_e *MockPrompter_Expecter) Int(prompt any, defaultValue any) *MockPrompter_Int_Call

Int is a helper method to define mock.On call

  • prompt string
  • defaultValue int

func (*MockPrompter_Expecter) String

func (_e *MockPrompter_Expecter) String(prompt any, defaultValue any) *MockPrompter_String_Call

String is a helper method to define mock.On call

  • prompt string
  • defaultValue string

func (*MockPrompter_Expecter) StringSlice

func (_e *MockPrompter_Expecter) StringSlice(prompt any, defaultValue any) *MockPrompter_StringSlice_Call

StringSlice is a helper method to define mock.On call

  • prompt string
  • defaultValue []string

type MockPrompter_Int_Call

type MockPrompter_Int_Call struct {
	*mock.Call
}

MockPrompter_Int_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Int'

func (*MockPrompter_Int_Call) Return

func (*MockPrompter_Int_Call) Run

func (_c *MockPrompter_Int_Call) Run(run func(prompt string, defaultValue int)) *MockPrompter_Int_Call

func (*MockPrompter_Int_Call) RunAndReturn

func (_c *MockPrompter_Int_Call) RunAndReturn(run func(prompt string, defaultValue int) int) *MockPrompter_Int_Call

type MockPrompter_StringSlice_Call

type MockPrompter_StringSlice_Call struct {
	*mock.Call
}

MockPrompter_StringSlice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StringSlice'

func (*MockPrompter_StringSlice_Call) Return

func (*MockPrompter_StringSlice_Call) Run

func (_c *MockPrompter_StringSlice_Call) Run(run func(prompt string, defaultValue []string)) *MockPrompter_StringSlice_Call

func (*MockPrompter_StringSlice_Call) RunAndReturn

func (_c *MockPrompter_StringSlice_Call) RunAndReturn(run func(prompt string, defaultValue []string) []string) *MockPrompter_StringSlice_Call

type MockPrompter_String_Call

type MockPrompter_String_Call struct {
	*mock.Call
}

MockPrompter_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String'

func (*MockPrompter_String_Call) Return

func (*MockPrompter_String_Call) Run

func (_c *MockPrompter_String_Call) Run(run func(prompt string, defaultValue string)) *MockPrompter_String_Call

func (*MockPrompter_String_Call) RunAndReturn

func (_c *MockPrompter_String_Call) RunAndReturn(run func(prompt string, defaultValue string) string) *MockPrompter_String_Call

type Prompter

type Prompter interface {
	String(prompt, defaultValue string) string
	Int(prompt string, defaultValue int) int
	StringSlice(prompt string, defaultValue []string) []string
	Bool(prompt string, defaultValue bool) bool
	Choice(prompt string, choices []string, defaultValue string) string
}

Prompter asks the operator a question and returns their answer, falling back to the default whenever there is none: an empty line, a closed stdin, or a prompter that was created non-interactive.

type StdinPrompter

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

StdinPrompter is the Prompter that asks on stdin.

func NewPrompter

func NewPrompter(interactive bool) *StdinPrompter

NewPrompter returns a prompter reading from stdin. A non-interactive one never asks and answers every question with its default.

func (*StdinPrompter) Bool

func (p *StdinPrompter) Bool(prompt string, defaultValue bool) bool

Bool asks a yes/no question. Only "y" and "yes" are a yes, only "n" and "no" a no; anything else falls back to the default.

func (*StdinPrompter) Choice

func (p *StdinPrompter) Choice(prompt string, choices []string, defaultValue string) string

Choice asks for one of the given options, falling back to the default when the answer is not among them.

func (*StdinPrompter) Int

func (p *StdinPrompter) Int(prompt string, defaultValue int) int

Int asks for a number, falling back to the default when the answer is not one.

func (*StdinPrompter) String

func (p *StdinPrompter) String(prompt, defaultValue string) string

String asks for a line of text.

func (*StdinPrompter) StringSlice

func (p *StdinPrompter) StringSlice(prompt string, defaultValue []string) []string

StringSlice asks for a comma-separated list.

Jump to

Keyboard shortcuts

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