Documentation ¶
Index ¶
- type MockConsole
- func (c *MockConsole) Confirm(ctx context.Context, options input.ConsoleOptions) (bool, error)
- func (c *MockConsole) EnsureBlankLine(context context.Context)
- func (c *MockConsole) Flush()
- func (c *MockConsole) GetFormatter() output.Formatter
- func (c *MockConsole) GetWriter() io.Writer
- func (c *MockConsole) Handles() input.ConsoleHandles
- func (c *MockConsole) IsSpinnerInteractive() bool
- func (c *MockConsole) IsSpinnerRunning(ctx context.Context) bool
- func (c *MockConsole) IsUnformatted() bool
- func (c *MockConsole) Message(ctx context.Context, message string)
- func (c *MockConsole) MessageUxItem(ctx context.Context, item ux.UxItem)
- func (c *MockConsole) MultiSelect(ctx context.Context, options input.ConsoleOptions) ([]string, error)
- func (c *MockConsole) Output() []string
- func (c *MockConsole) Prompt(ctx context.Context, options input.ConsoleOptions) (string, error)
- func (c *MockConsole) PromptDialog(ctx context.Context, dialog input.PromptDialog) (map[string]any, error)
- func (c *MockConsole) PromptFs(ctx context.Context, options input.ConsoleOptions, fs input.FsOptions) (string, error)
- func (c *MockConsole) Select(ctx context.Context, options input.ConsoleOptions) (int, error)
- func (c *MockConsole) SetWriter(writer io.Writer)
- func (c *MockConsole) ShowPreviewer(ctx context.Context, options *input.ShowPreviewerOptions) io.Writer
- func (c *MockConsole) ShowSpinner(ctx context.Context, title string, format input.SpinnerUxType)
- func (c *MockConsole) SpinnerOps() []SpinnerOp
- func (c *MockConsole) StopPreviewer(ctx context.Context, keepLogs bool)
- func (c *MockConsole) StopSpinner(ctx context.Context, lastMessage string, format input.SpinnerUxType)
- func (c *MockConsole) SupportsPromptDialog() bool
- func (c *MockConsole) WaitForEnter()
- func (c *MockConsole) WarnForFeature(ctx context.Context, id alpha.FeatureId)
- func (c *MockConsole) WhenConfirm(predicate WhenPredicate) *MockConsoleExpression
- func (c *MockConsole) WhenPrompt(predicate WhenPredicate) *MockConsoleExpression
- func (c *MockConsole) WhenSelect(predicate WhenPredicate) *MockConsoleExpression
- type MockConsoleExpression
- type RespondFn
- type SpinnerOp
- type SpinnerOpType
- type WhenPredicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockConsole ¶
type MockConsole struct {
// contains filtered or unexported fields
}
A mock implementation of the input.Console interface
func NewMockConsole ¶
func NewMockConsole() *MockConsole
func (*MockConsole) Confirm ¶
func (c *MockConsole) Confirm(ctx context.Context, options input.ConsoleOptions) (bool, error)
Prints a confirmation message to the console for the user to confirm
func (*MockConsole) EnsureBlankLine ¶
func (c *MockConsole) EnsureBlankLine(context context.Context)
func (*MockConsole) GetFormatter ¶
func (c *MockConsole) GetFormatter() output.Formatter
func (*MockConsole) GetWriter ¶
func (c *MockConsole) GetWriter() io.Writer
func (*MockConsole) Handles ¶
func (c *MockConsole) Handles() input.ConsoleHandles
func (*MockConsole) IsSpinnerInteractive ¶
func (c *MockConsole) IsSpinnerInteractive() bool
func (*MockConsole) IsSpinnerRunning ¶
func (c *MockConsole) IsSpinnerRunning(ctx context.Context) bool
func (*MockConsole) IsUnformatted ¶
func (c *MockConsole) IsUnformatted() bool
func (*MockConsole) Message ¶
func (c *MockConsole) Message(ctx context.Context, message string)
Prints a message to the console
func (*MockConsole) MessageUxItem ¶
func (c *MockConsole) MessageUxItem(ctx context.Context, item ux.UxItem)
func (*MockConsole) MultiSelect ¶
func (c *MockConsole) MultiSelect(ctx context.Context, options input.ConsoleOptions) ([]string, error)
Writes a multiple choice selection to the console for the user to choose
func (*MockConsole) Output ¶
func (c *MockConsole) Output() []string
func (*MockConsole) Prompt ¶
func (c *MockConsole) Prompt(ctx context.Context, options input.ConsoleOptions) (string, error)
Writes a single answer prompt to the console for the user to complete
func (*MockConsole) PromptDialog ¶
func (c *MockConsole) PromptDialog(ctx context.Context, dialog input.PromptDialog) (map[string]any, error)
func (*MockConsole) PromptFs ¶
func (c *MockConsole) PromptFs(ctx context.Context, options input.ConsoleOptions, fs input.FsOptions) (string, error)
func (*MockConsole) Select ¶
func (c *MockConsole) Select(ctx context.Context, options input.ConsoleOptions) (int, error)
Writes a multiple choice selection to the console for the user to choose
func (*MockConsole) SetWriter ¶
func (c *MockConsole) SetWriter(writer io.Writer)
func (*MockConsole) ShowPreviewer ¶
func (c *MockConsole) ShowPreviewer(ctx context.Context, options *input.ShowPreviewerOptions) io.Writer
func (*MockConsole) ShowSpinner ¶
func (c *MockConsole) ShowSpinner(ctx context.Context, title string, format input.SpinnerUxType)
func (*MockConsole) SpinnerOps ¶
func (c *MockConsole) SpinnerOps() []SpinnerOp
func (*MockConsole) StopPreviewer ¶
func (c *MockConsole) StopPreviewer(ctx context.Context, keepLogs bool)
func (*MockConsole) StopSpinner ¶
func (c *MockConsole) StopSpinner(ctx context.Context, lastMessage string, format input.SpinnerUxType)
func (*MockConsole) SupportsPromptDialog ¶
func (c *MockConsole) SupportsPromptDialog() bool
func (*MockConsole) WaitForEnter ¶
func (c *MockConsole) WaitForEnter()
no-op for mock-console when calling WaitForEnter()
func (*MockConsole) WarnForFeature ¶
func (c *MockConsole) WarnForFeature(ctx context.Context, id alpha.FeatureId)
func (*MockConsole) WhenConfirm ¶
func (c *MockConsole) WhenConfirm(predicate WhenPredicate) *MockConsoleExpression
Registers a confirmation expression for mocking in unit tests
func (*MockConsole) WhenPrompt ¶
func (c *MockConsole) WhenPrompt(predicate WhenPredicate) *MockConsoleExpression
Registers a prompt expression for mocking in unit tests
func (*MockConsole) WhenSelect ¶
func (c *MockConsole) WhenSelect(predicate WhenPredicate) *MockConsoleExpression
Registers a multiple choice selection express for mocking in unit tests
type MockConsoleExpression ¶
type MockConsoleExpression struct {
// contains filtered or unexported fields
}
MockConsoleExpression is an expression with options response or error
func (*MockConsoleExpression) Respond ¶
func (e *MockConsoleExpression) Respond(value any) *MockConsole
Sets the response that will be returned for the current expression
func (*MockConsoleExpression) RespondFn ¶
func (e *MockConsoleExpression) RespondFn(respond RespondFn) *MockConsole
Sets the function that will be used to provide the response or error for the current expression
func (*MockConsoleExpression) SetError ¶
func (e *MockConsoleExpression) SetError(err error) *MockConsole
Sets the error that will be returned for the current expression
type RespondFn ¶
type RespondFn func(options input.ConsoleOptions) (any, error)
An action definition for providing responses or errors for an interaction
type SpinnerOp ¶
type SpinnerOp struct { Op SpinnerOpType Message string Format input.SpinnerUxType }
type SpinnerOpType ¶
type SpinnerOpType string
const SpinnerOpShow SpinnerOpType = "show"
const SpinnerOpStop SpinnerOpType = "stop"
type WhenPredicate ¶
type WhenPredicate func(options input.ConsoleOptions) bool
A predicate function definition for registering expressions