Documentation ¶
Overview ¶
Package output is a generated GoMock package.
Index ¶
- Constants
- Variables
- func CompleteStep(step Step)
- func FormatResourceForDisplay(id ucpresources.ID) string
- func FormatResourceForProgressDisplay(id ucpresources.ID) string
- func FormatResourceNameForDisplay(id ucpresources.ID) string
- func FormatResourceTypeForDisplay(id ucpresources.ID) string
- func LogInfo(format string, v ...any)
- func ShowResource(id ucpresources.ID) bool
- func SupportedFormats() []string
- func Write(format string, obj any, writer io.Writer, options FormatterOptions) error
- type Column
- type FormattedOutput
- type Formatter
- type FormatterOptions
- type Interface
- type JSONFormatter
- type LogOutput
- type MockInterface
- type MockInterfaceMockRecorder
- type MockOutput
- type OutputWriter
- type Step
- type Stream
- type StreamGroup
- type StreamWriter
- type TableFormatter
Constants ¶
const ( FormatJson = "json" FormatTable = "table" DefaultFormat = FormatTable )
const ( ProgressFailed = "Failed" ProgressCompleted = "Completed" )
const ( TableColumnMinWidth = 10 TableTabSize = 4 TablePadSize = 2 TablePadCharacter = ' ' TableFlags = 0 )
Variables ¶
var ProgressDefaultSpinner = []string{". ", ".. ", "..."}
Functions ¶
func FormatResourceForDisplay ¶
func FormatResourceForDisplay(id ucpresources.ID) string
FormatResourceForDisplay returns a display string for the resource type and name.
func FormatResourceForProgressDisplay ¶
func FormatResourceForProgressDisplay(id ucpresources.ID) string
FormatResourceForProgressDisplay returns a display string for a progress spinner, resource type, and name.
func FormatResourceNameForDisplay ¶
func FormatResourceNameForDisplay(id ucpresources.ID) string
FormatResourceNameForDisplay returns a display string for the resource name.
func FormatResourceTypeForDisplay ¶
func FormatResourceTypeForDisplay(id ucpresources.ID) string
FormatResourceTypeForDisplay returns a display string for the resource type.
func ShowResource ¶
func ShowResource(id ucpresources.ID) bool
ShowResource returns true if the resource should be displayed to the user.
func SupportedFormats ¶
func SupportedFormats() []string
SupportedFormats returns a slice of strings containing the supported formats for a request.
Types ¶
type FormattedOutput ¶
type FormattedOutput struct { Format string Obj any Options FormatterOptions }
type Formatter ¶
type Formatter interface {
Format(obj any, writer io.Writer, options FormatterOptions) error
}
func NewFormatter ¶
NewFormatter takes in a string and returns a Formatter interface and an error if the format is not supported.
type FormatterOptions ¶
type FormatterOptions struct { // Columns used for table formatting Columns []Column }
type Interface ¶
type Interface interface { // LogInfo logs a message that is displayed to the user by default. LogInfo(format string, v ...any) // Write WriteFormatted(format string, obj any, options FormatterOptions) error }
Interface is a mockable interface for writing cli output
type JSONFormatter ¶
type JSONFormatter struct { }
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(obj any, writer io.Writer, options FormatterOptions) error
Format takes in an object, a writer and an options object and marshals the object into JSON, writing it to the writer, and returns an error if any of the operations fail.
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) Write ¶
func (m *MockInterface) Write(arg0 string, arg1 any, arg2 FormatterOptions) error
Write mocks base method.
type MockInterfaceMockRecorder ¶
type MockInterfaceMockRecorder struct {
// contains filtered or unexported fields
}
MockInterfaceMockRecorder is the mock recorder for MockInterface.
type MockOutput ¶
type MockOutput struct {
Writes []any
}
func (*MockOutput) LogInfo ¶
func (o *MockOutput) LogInfo(format string, v ...any)
LogInfo takes in a format string and a variable number of parameters and appends them to the Writes slice.
func (*MockOutput) WriteFormatted ¶
func (o *MockOutput) WriteFormatted(format string, obj any, options FormatterOptions) error
WriteFormatted takes in a format string, an object of any type, and a FormatterOptions object, and appends them to the Writes slice, returning no error.
type OutputWriter ¶
func (*OutputWriter) LogInfo ¶
func (o *OutputWriter) LogInfo(format string, v ...any)
LogInfo takes in a format string and a variable number of arguments and prints the formatted string to the Writer.
func (*OutputWriter) WriteFormatted ¶
func (o *OutputWriter) WriteFormatted(format string, obj any, options FormatterOptions) error
WriteFormatted takes in a format string, an object of any type, and a FormatterOptions object, and calls the Write function with the given parameters, writing the output to the Writer field of the OutputWriter object.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Print ¶
Print takes a string and prints it to the output stream with a prefix of the stream's name in a secondary color.
func (*Stream) Writer ¶
func (s *Stream) Writer() io.WriteCloser
Writer() returns an io.WriteCloser which is a StreamWriter struct that contains a pointer to the Stream struct.
type StreamGroup ¶
type StreamGroup struct {
// contains filtered or unexported fields
}
StreamGroup represents a group of related output streams of different colors. All functionality of StreamGroup can be used concurrently.
func NewStreamGroup ¶
func NewStreamGroup(out io.Writer) *StreamGroup
NewStreamGroup creates a new StreamGroup object with an output writer and a mutex, and returns a pointer to the newly created StreamGroup.
func (*StreamGroup) NewStream ¶
func (sg *StreamGroup) NewStream(name string) *Stream
NewStream() creates a new Stream object with a given name, assigns it a primary and secondary color, and returns it.
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter implements io.Writer for a Stream.
func (*StreamWriter) Close ¶
func (w *StreamWriter) Close() error
Close flushes the stream and returns an error if the flush fails.
type TableFormatter ¶
type TableFormatter struct { }
func (*TableFormatter) Format ¶
func (f *TableFormatter) Format(obj any, writer io.Writer, options FormatterOptions) error
Format() takes in an object, a writer and formatting options and writes a table to the writer using the formatting options. If no columns are defined, an error is returned.