Documentation
¶
Index ¶
- func TrimSpace(val any) any
- type ConfirmFunc
- type InputFunc
- type MultiSelectFunc
- type Prompter
- type PrompterMock
- func (mock *PrompterMock) Confirm(msg string, value bool, help string) (bool, error)
- func (mock *PrompterMock) ConfirmCalls() []struct{ ... }
- func (mock *PrompterMock) Input(msg string, value string, help string) (string, error)
- func (mock *PrompterMock) InputCalls() []struct{ ... }
- func (mock *PrompterMock) MultiSelect(msg string, options []string, values []string, help string) ([]string, error)
- func (mock *PrompterMock) MultiSelectCalls() []struct{ ... }
- func (mock *PrompterMock) Select(msg string, options []string, value string, help string) (string, error)
- func (mock *PrompterMock) SelectCalls() []struct{ ... }
- type SelectFunc
- type SurveyPrompter
- func (p *SurveyPrompter) Confirm(prompt string, defaultValue bool, help string) (bool, error)
- func (p *SurveyPrompter) Input(prompt string, defaultValue string, help string) (string, error)
- func (p *SurveyPrompter) MultiSelect(prompt string, options []string, defaultValues []string, help string) ([]string, error)
- func (p *SurveyPrompter) Select(prompt string, options []string, defaultValue string, help string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConfirmFunc ¶
func NewConfirmFunc ¶
func NewConfirmFunc(result bool, err error) ConfirmFunc
Creates a new ConfirmFunc that returns the given result and err.
func NewConfirmFuncSet ¶
func NewConfirmFuncSet(funcs ...ConfirmFunc) ConfirmFunc
Creates a new ConfirmFunc that delegates to funcs in series.
func NewNoopConfirmFunc ¶
func NewNoopConfirmFunc() ConfirmFunc
Creates a new ConfirmFunc that returns the default value.
type InputFunc ¶
func NewInputFunc ¶
Creates a new InputFunc that returns the given result and err.
func NewInputFuncSet ¶
Creates a new InputFunc that delegates to funcs in series.
func NewNoopInputFunc ¶
func NewNoopInputFunc() InputFunc
Creates a new InputFunc that returns the default value.
type MultiSelectFunc ¶
type MultiSelectFunc func(msg string, options []string, values []string, help string) ([]string, error)
func NewMultiSelectFunc ¶
func NewMultiSelectFunc(result []string, err error) MultiSelectFunc
Creates a new SelectFunc that returns the given result and err.
func NewNoopMultiSelectFunc ¶
func NewNoopMultiSelectFunc() MultiSelectFunc
Creates a new InputFunc that returns the default value.
type Prompter ¶
type Prompter interface {
// Prompt for a boolean yes/no value.
Confirm(msg string, value bool, help string) (bool, error)
// Prompt for single string value.
Input(msg string, value string, help string) (string, error)
// Prompt for a slice of string values w/ a fixed set of options.
MultiSelect(msg string, options []string, values []string, help string) ([]string, error)
// Prompt for single string value w/ a fixed set of options.
Select(msg string, options []string, value string, help string) (string, error)
}
type PrompterMock ¶
type PrompterMock struct {
// ConfirmFunc mocks the Confirm method.
ConfirmFunc func(msg string, value bool, help string) (bool, error)
// InputFunc mocks the Input method.
InputFunc func(msg string, value string, help string) (string, error)
// MultiSelectFunc mocks the MultiSelect method.
MultiSelectFunc func(msg string, options []string, values []string, help string) ([]string, error)
// SelectFunc mocks the Select method.
SelectFunc func(msg string, options []string, value string, help string) (string, error)
// contains filtered or unexported fields
}
PrompterMock is a mock implementation of Prompter.
func TestSomethingThatUsesPrompter(t *testing.T) {
// make and configure a mocked Prompter
mockedPrompter := &PrompterMock{
ConfirmFunc: func(msg string, value bool, help string) (bool, error) {
panic("mock out the Confirm method")
},
InputFunc: func(msg string, value string, help string) (string, error) {
panic("mock out the Input method")
},
MultiSelectFunc: func(msg string, options []string, values []string, help string) ([]string, error) {
panic("mock out the MultiSelect method")
},
SelectFunc: func(msg string, options []string, value string, help string) (string, error) {
panic("mock out the Select method")
},
}
// use mockedPrompter in code that requires Prompter
// and then make assertions.
}
func (*PrompterMock) ConfirmCalls ¶
func (mock *PrompterMock) ConfirmCalls() []struct { Msg string Value bool Help string }
ConfirmCalls gets all the calls that were made to Confirm. Check the length with:
len(mockedPrompter.ConfirmCalls())
func (*PrompterMock) InputCalls ¶
func (mock *PrompterMock) InputCalls() []struct { Msg string Value string Help string }
InputCalls gets all the calls that were made to Input. Check the length with:
len(mockedPrompter.InputCalls())
func (*PrompterMock) MultiSelect ¶
func (mock *PrompterMock) MultiSelect(msg string, options []string, values []string, help string) ([]string, error)
MultiSelect calls MultiSelectFunc.
func (*PrompterMock) MultiSelectCalls ¶
func (mock *PrompterMock) MultiSelectCalls() []struct { Msg string Options []string Values []string Help string }
MultiSelectCalls gets all the calls that were made to MultiSelect. Check the length with:
len(mockedPrompter.MultiSelectCalls())
func (*PrompterMock) Select ¶
func (mock *PrompterMock) Select(msg string, options []string, value string, help string) (string, error)
Select calls SelectFunc.
func (*PrompterMock) SelectCalls ¶
func (mock *PrompterMock) SelectCalls() []struct { Msg string Options []string Value string Help string }
SelectCalls gets all the calls that were made to Select. Check the length with:
len(mockedPrompter.SelectCalls())
type SelectFunc ¶
func NewNoopSelectFunc ¶
func NewNoopSelectFunc() SelectFunc
Creates a new InputFunc that returns the default value.
func NewSelectFunc ¶
func NewSelectFunc(result string, err error) SelectFunc
Creates a new SelectFunc that returns the given result and err.
func NewSelectFuncSet ¶
func NewSelectFuncSet(funcs ...SelectFunc) SelectFunc
Creates a new SelectFunc that delegates to funcs in series.
type SurveyPrompter ¶
type SurveyPrompter struct {
// contains filtered or unexported fields
}
func NewSurveyPrompter ¶
func NewSurveyPrompter(in fileReader, out fileWriter, err fileWriter, ios ioSession) *SurveyPrompter