Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintError ¶
PrintError outputs the formatted error to stderr
Types ¶
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code,omitempty"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
Timestamp string `json:"timestamp"`
}
ErrorDetail contains error details
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents a JSON error response
type FormatType ¶
type FormatType string
FormatType represents the output format type
const ( FormatJSON FormatType = "json" FormatTable FormatType = "table" FormatPlain FormatType = "plain" )
type Formatter ¶
type Formatter interface {
// Format converts data to the appropriate output format
Format(data interface{}) (string, error)
// FormatError formats an error for output
FormatError(err error) string
}
Formatter defines the interface for output formatting
func NewFormatter ¶
NewFormatter creates a formatter based on options
type JSONFormatter ¶
type JSONFormatter struct {
// contains filtered or unexported fields
}
JSONFormatter formats output as JSON
func NewJSONFormatter ¶
func NewJSONFormatter(opts Options) *JSONFormatter
NewJSONFormatter creates a new JSON formatter
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(data interface{}) (string, error)
Format converts data to JSON format
func (*JSONFormatter) FormatError ¶
func (f *JSONFormatter) FormatError(err error) string
FormatError formats an error as JSON
type PlainFormatter ¶
type PlainFormatter struct {
// contains filtered or unexported fields
}
PlainFormatter formats output as plain pipe-delimited text
func NewPlainFormatter ¶
func NewPlainFormatter(opts Options) *PlainFormatter
NewPlainFormatter creates a new plain text formatter
func (*PlainFormatter) Format ¶
func (f *PlainFormatter) Format(data interface{}) (string, error)
Format converts data to plain text format
func (*PlainFormatter) FormatError ¶
func (f *PlainFormatter) FormatError(err error) string
FormatError formats an error as plain text
type SimpleTable ¶
type SimpleTable struct {
// contains filtered or unexported fields
}
SimpleTable is a helper struct for simple tabular data
func NewSimpleTable ¶
func NewSimpleTable(headers []string) *SimpleTable
NewSimpleTable creates a new simple table
func (*SimpleTable) AddRow ¶
func (t *SimpleTable) AddRow(row ...string)
AddRow adds a row to the table
func (*SimpleTable) Headers ¶
func (t *SimpleTable) Headers() []string
Headers returns the table headers
type TableFormatter ¶
type TableFormatter struct {
// contains filtered or unexported fields
}
TableFormatter formats output as a styled table
func NewTableFormatter ¶
func NewTableFormatter(opts Options) *TableFormatter
NewTableFormatter creates a new table formatter
func (*TableFormatter) Format ¶
func (f *TableFormatter) Format(data interface{}) (string, error)
Format converts data to a styled table format
func (*TableFormatter) FormatError ¶
func (f *TableFormatter) FormatError(err error) string
FormatError formats an error for table output