Documentation ¶
Index ¶
- type Messenger
- func (m *Messenger) Failure(line string, args ...any)
- func (m *Messenger) FailureErr(line string, args ...any)
- func (m *Messenger) FailureTag(tag string, line string, args ...any)
- func (m *Messenger) FailureTagErr(tag string, line string, args ...any)
- func (m *Messenger) Info(line string, args ...any)
- func (m *Messenger) InfoErr(line string, args ...any)
- func (m *Messenger) InfoTag(tag string, line string, args ...any)
- func (m *Messenger) InfoTagErr(tag string, line string, args ...any)
- func (m *Messenger) Success(line string, args ...any)
- func (m *Messenger) SuccessErr(line string, args ...any)
- func (m *Messenger) SuccessTag(tag string, line string, args ...any)
- func (m *Messenger) SuccessTagErr(tag string, line string, args ...any)
- func (m *Messenger) Warning(line string, args ...any)
- func (m *Messenger) WarningErr(line string, args ...any)
- func (m *Messenger) WarningTag(tag string, line string, args ...any)
- func (m *Messenger) WarningTagErr(tag string, line string, args ...any)
- 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 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 ¶
This section is empty.
Types ¶
type Messenger ¶
type Messenger struct {
// contains filtered or unexported fields
}
Messenger is a generic logger that prefixes lines with status icons.
func NewMessenger ¶
NewMessenger returns a new IconLogger.
func (*Messenger) FailureErr ¶
FailureErr prints line to StdErr prefixed with "✖".
func (*Messenger) FailureTag ¶
FailureTag prints line to StdOut prefixed with "✖ [tag] ".
func (*Messenger) FailureTagErr ¶
FailureTagErr prints line to StdErr prefixed with "✖ [tag] ".
func (*Messenger) InfoTagErr ¶
InfoTagErr prints line to StdErr prefixed with "• [tag] ".
func (*Messenger) SuccessErr ¶
SuccessErr prints line to StdErr prefixed with "✓".
func (*Messenger) SuccessTag ¶
SuccessTag prints line to StdOut prefixed with "✓ [tag] ".
func (*Messenger) SuccessTagErr ¶
SuccessTagErr prints line to StdErr prefixed with "✓ [tag] ".
func (*Messenger) WarningErr ¶
WarningErr prints line to StdErr prefixed with "!".
func (*Messenger) WarningTag ¶
WarningTag prints line to StdOut prefixed with "! [tag] ".
type Prompter ¶
type Prompter interface { // Confirm prompts for a boolean yes/no value. Confirm(msg string, value bool, help string) (bool, error) // Input prompts for single string value. Input(msg string, value string, help string) (string, error) // MultiSelect prompts for a slice of string values w/ a fixed set of options. MultiSelect(msg string, options []string, values []string, help string) ([]string, error) // Select prompts for single string value w/ a fixed set of options. Select(msg string, options []string, value string, help string) (string, error) }
Prompter is an interface for types that prompt for user input.
type PrompterMock ¶ added in v0.2.0
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 NewPrompterMock ¶ added in v0.2.0
func NewPrompterMock() *PrompterMock
NewPrompterMock returns a new mock prompter.
func (*PrompterMock) ConfirmCalls ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (mock *PrompterMock) MultiSelect(msg string, options []string, values []string, help string) ([]string, error)
MultiSelect calls MultiSelectFunc.
func (*PrompterMock) MultiSelectCalls ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (mock *PrompterMock) Select(msg string, options []string, value string, help string) (string, error)
Select calls SelectFunc.
func (*PrompterMock) SelectCalls ¶ added in v0.2.0
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 SurveyPrompter ¶
type SurveyPrompter struct {
// contains filtered or unexported fields
}
SurveyPrompter is a light wrapper around the survey(https://github.com/go-survey/survey) library.
func NewSurveyPrompter ¶
func NewSurveyPrompter(in fileReader, out fileWriter, err fileWriter, s session) *SurveyPrompter
func (*SurveyPrompter) MultiSelect ¶
func (p *SurveyPrompter) MultiSelect( prompt string, options []string, defaultValues []string, help string, ) ([]string, error)
MultiSelect prompts for a slice of string values w/ a fixed set of options.