Documentation ¶
Overview ¶
Package prompt is a generated GoMock package.
Index ¶
- Constants
- func ValidateApplicationName(input string) error
- func ValidateKubernetesNamespace(input string) error
- func ValidateKubernetesNamespaceOrDefault(input string) error
- func ValidateResourceName(input string) error
- func ValidateResourceNameOrDefault(input string) error
- func ValidateUUIDv4(input string) error
- func YesOrNoPrompt(promptMsg string, defaultString string, prompter Interface) (bool, error)
- type ErrExitConsole
- type ErrUnsupportedModel
- type Impl
- type Interface
- type MockInterface
- func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder
- func (m *MockInterface) GetListInput(arg0 []string, arg1 string) (string, error)
- func (m *MockInterface) GetTextInput(arg0 string, arg1 text.TextModelOptions) (string, error)
- func (m *MockInterface) RunProgram(arg0 *tea.Program) (tea.Model, error)
- type MockInterfaceGetListInputCall
- func (c *MockInterfaceGetListInputCall) Do(f func([]string, string) (string, error)) *MockInterfaceGetListInputCall
- func (c *MockInterfaceGetListInputCall) DoAndReturn(f func([]string, string) (string, error)) *MockInterfaceGetListInputCall
- func (c *MockInterfaceGetListInputCall) Return(arg0 string, arg1 error) *MockInterfaceGetListInputCall
- type MockInterfaceGetTextInputCall
- func (c *MockInterfaceGetTextInputCall) Do(f func(string, text.TextModelOptions) (string, error)) *MockInterfaceGetTextInputCall
- func (c *MockInterfaceGetTextInputCall) DoAndReturn(f func(string, text.TextModelOptions) (string, error)) *MockInterfaceGetTextInputCall
- func (c *MockInterfaceGetTextInputCall) Return(arg0 string, arg1 error) *MockInterfaceGetTextInputCall
- type MockInterfaceMockRecorder
- type MockInterfaceRunProgramCall
- func (c *MockInterfaceRunProgramCall) Do(f func(*tea.Program) (tea.Model, error)) *MockInterfaceRunProgramCall
- func (c *MockInterfaceRunProgramCall) DoAndReturn(f func(*tea.Program) (tea.Model, error)) *MockInterfaceRunProgramCall
- func (c *MockInterfaceRunProgramCall) Return(arg0 tea.Model, arg1 error) *MockInterfaceRunProgramCall
- type TextInputOptions
Constants ¶
const ( // ConfirmYes can be used with YesOrNoPrompt to create a confirmation dialog. ConfirmYes = "Yes" // ConfirmNo can be used with YesOrNoPrompt to create a confirmation dialog. ConfirmNo = "No" )
const (
// ErrExitConsoleMessage is the message that is displayed when the user exits the console. This is exported for use in tests.
ErrExitConsoleMessage = "exiting command"
)
Variables ¶
This section is empty.
Functions ¶
func ValidateApplicationName ¶ added in v0.34.0
ValidateApplicationName checks if the given string is a valid Application name, and returns an error if it is not. The rules for application name matches that of kubernetes namespace since we use the name to also create a namespace for the application.
func ValidateKubernetesNamespace ¶
ValidateKubernetesNamespace checks if the input string is a valid Kubernetes namespace name, and returns an error if it is not.
func ValidateKubernetesNamespaceOrDefault ¶
ValidateKubernetesNamespaceOrDefault checks if the input is an empty string, and if so, returns nil, otherwise it calls ValidateKubernetesNamespace and returns the result. If ValidateKubernetesNamespace returns an error, ValidateKubernetesNamespaceOrDefault will also return an error.
func ValidateResourceName ¶
ValidateResourceName checks if the given string is a valid resource name, and returns an error if it is not.
func ValidateResourceNameOrDefault ¶
ValidateResourceNameOrDefault checks if the input string is empty, and if it is, returns nil, otherwise it calls the ValidateResourceName function to check if the input string is valid.
func ValidateUUIDv4 ¶
ValidateUUIDv4 checks if the input string is a valid UUIDv4 and returns an error if it is not.
func YesOrNoPrompt ¶
YesOrNoPrompt takes in a prompt message, a default string and a prompter interface, and returns a boolean value and an error if one occurs. It checks if the default string is equal to "yes", and if so, sets the value list to ["yes", "no"], otherwise it sets the value list to ["no", "yes"]. It then gets a list input from the prompter interface, and returns true if the input is equal to "yes", and false otherwise.
Types ¶
type ErrExitConsole ¶
type ErrExitConsole struct { }
ErrExitConsole represents interrupt commands being entered.
func (*ErrExitConsole) Error ¶
func (e *ErrExitConsole) Error() string
Error returns the error message.
func (*ErrExitConsole) Is ¶
func (e *ErrExitConsole) Is(target error) bool
Is checks for the error type is ErrExitConsole.
func (*ErrExitConsole) IsFriendlyError ¶
func (*ErrExitConsole) IsFriendlyError() bool
IsFriendlyError returns true. Cancelling a command prompt should always be handled gracefully by the CLI.
type ErrUnsupportedModel ¶
type ErrUnsupportedModel struct {
Message string
}
ErrUnsupportedModel represents error when invalid bubble tea model is used for operations.
func (*ErrUnsupportedModel) Error ¶
func (e *ErrUnsupportedModel) Error() string
ErrUnsupportedModel returns the error message.
func (*ErrUnsupportedModel) Is ¶
func (e *ErrUnsupportedModel) Is(target error) bool
Is checks if the error provided is of type ErrUnsupportedModel.
type Impl ¶
type Impl struct{}
Impl implements BubbleTeaPrompter
func (*Impl) GetListInput ¶
GetListInput displays a list of strings to the user and returns the user's selection as a string, or an error if the user exits the console or an unsupported model is encountered.
func (*Impl) GetTextInput ¶
func (i *Impl) GetTextInput(prompt string, options TextInputOptions) (string, error)
GetTextInput takes a prompt string and a set of options, and returns a string or an error if the user exits the console or an unsupported model is encountered.
type Interface ¶
type Interface interface { // GetTextInput prompts user for a text input. Will return ErrExitConsole if the user cancels. GetTextInput(prompt string, options TextInputOptions) (string, error) // GetListInput prompts user to select from a list. Will return ErrExitConsole if the user cancels. GetListInput(items []string, promptMsg string) (string, error) // RunProgram runs a bubbletea program and blocks until the program exits. // // To create a cancellable program, use the options to pass a context.Context into the program. RunProgram(program *tea.Program) (tea.Model, error) }
Interface contains operation to prompt the user interactively.
All functions on Interface returns an *ErrExitConsole if the user cancels. This is a friendly error and does not need special handling by calling code.
type MockInterface ¶
type MockInterface struct {
// contains filtered or unexported fields
}
MockInterface is a mock of Interface interface.
func NewMockInterface ¶
func NewMockInterface(ctrl *gomock.Controller) *MockInterface
NewMockInterface creates a new mock instance.
func (*MockInterface) EXPECT ¶
func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockInterface) GetListInput ¶
func (m *MockInterface) GetListInput(arg0 []string, arg1 string) (string, error)
GetListInput mocks base method.
func (*MockInterface) GetTextInput ¶
func (m *MockInterface) GetTextInput(arg0 string, arg1 text.TextModelOptions) (string, error)
GetTextInput mocks base method.
func (*MockInterface) RunProgram ¶
RunProgram mocks base method.
type MockInterfaceGetListInputCall ¶ added in v0.35.0
MockInterfaceGetListInputCall wrap *gomock.Call
func (*MockInterfaceGetListInputCall) Do ¶ added in v0.35.0
func (c *MockInterfaceGetListInputCall) Do(f func([]string, string) (string, error)) *MockInterfaceGetListInputCall
Do rewrite *gomock.Call.Do
func (*MockInterfaceGetListInputCall) DoAndReturn ¶ added in v0.35.0
func (c *MockInterfaceGetListInputCall) DoAndReturn(f func([]string, string) (string, error)) *MockInterfaceGetListInputCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockInterfaceGetListInputCall) Return ¶ added in v0.35.0
func (c *MockInterfaceGetListInputCall) Return(arg0 string, arg1 error) *MockInterfaceGetListInputCall
Return rewrite *gomock.Call.Return
type MockInterfaceGetTextInputCall ¶ added in v0.35.0
MockInterfaceGetTextInputCall wrap *gomock.Call
func (*MockInterfaceGetTextInputCall) Do ¶ added in v0.35.0
func (c *MockInterfaceGetTextInputCall) Do(f func(string, text.TextModelOptions) (string, error)) *MockInterfaceGetTextInputCall
Do rewrite *gomock.Call.Do
func (*MockInterfaceGetTextInputCall) DoAndReturn ¶ added in v0.35.0
func (c *MockInterfaceGetTextInputCall) DoAndReturn(f func(string, text.TextModelOptions) (string, error)) *MockInterfaceGetTextInputCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockInterfaceGetTextInputCall) Return ¶ added in v0.35.0
func (c *MockInterfaceGetTextInputCall) Return(arg0 string, arg1 error) *MockInterfaceGetTextInputCall
Return rewrite *gomock.Call.Return
type MockInterfaceMockRecorder ¶
type MockInterfaceMockRecorder struct {
// contains filtered or unexported fields
}
MockInterfaceMockRecorder is the mock recorder for MockInterface.
func (*MockInterfaceMockRecorder) GetListInput ¶
func (mr *MockInterfaceMockRecorder) GetListInput(arg0, arg1 any) *MockInterfaceGetListInputCall
GetListInput indicates an expected call of GetListInput.
func (*MockInterfaceMockRecorder) GetTextInput ¶
func (mr *MockInterfaceMockRecorder) GetTextInput(arg0, arg1 any) *MockInterfaceGetTextInputCall
GetTextInput indicates an expected call of GetTextInput.
func (*MockInterfaceMockRecorder) RunProgram ¶
func (mr *MockInterfaceMockRecorder) RunProgram(arg0 any) *MockInterfaceRunProgramCall
RunProgram indicates an expected call of RunProgram.
type MockInterfaceRunProgramCall ¶ added in v0.35.0
MockInterfaceRunProgramCall wrap *gomock.Call
func (*MockInterfaceRunProgramCall) Do ¶ added in v0.35.0
func (c *MockInterfaceRunProgramCall) Do(f func(*tea.Program) (tea.Model, error)) *MockInterfaceRunProgramCall
Do rewrite *gomock.Call.Do
func (*MockInterfaceRunProgramCall) DoAndReturn ¶ added in v0.35.0
func (c *MockInterfaceRunProgramCall) DoAndReturn(f func(*tea.Program) (tea.Model, error)) *MockInterfaceRunProgramCall
DoAndReturn rewrite *gomock.Call.DoAndReturn
func (*MockInterfaceRunProgramCall) Return ¶ added in v0.35.0
func (c *MockInterfaceRunProgramCall) Return(arg0 tea.Model, arg1 error) *MockInterfaceRunProgramCall
Return rewrite *gomock.Call.Return
type TextInputOptions ¶
type TextInputOptions = text.TextModelOptions
TextInputOptions contains options for 'Interface.GetTextInput'.