Documentation ¶
Overview ¶
Package prompt is a generated GoMock package.
Index ¶
- Constants
- 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 MockInterfaceMockRecorder
- 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 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 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 interface{}) *gomock.Call
GetListInput indicates an expected call of GetListInput.
func (*MockInterfaceMockRecorder) GetTextInput ¶
func (mr *MockInterfaceMockRecorder) GetTextInput(arg0, arg1 interface{}) *gomock.Call
GetTextInput indicates an expected call of GetTextInput.
func (*MockInterfaceMockRecorder) RunProgram ¶
func (mr *MockInterfaceMockRecorder) RunProgram(arg0 interface{}) *gomock.Call
RunProgram indicates an expected call of RunProgram.
type TextInputOptions ¶
type TextInputOptions = text.TextModelOptions
TextInputOptions contains options for 'Interface.GetTextInput'.