Documentation
¶
Index ¶
- func Error(v ...interface{})
- func ErrorWriter() io.Writer
- func Errorf(format string, v ...interface{})
- func OutputWriter() io.Writer
- func Print(v interface{})
- func PrintResult(res Result)
- func Printf(format string, v ...interface{})
- func SetDefaultFeedback(f *Feedback)
- func SetErr(err io.Writer)
- func SetFormat(f OutputFormat)
- func SetOut(out io.Writer)
- type Feedback
- func (fb *Feedback) Error(v ...interface{})
- func (fb *Feedback) ErrorWriter() io.Writer
- func (fb *Feedback) Errorf(format string, v ...interface{})
- func (fb *Feedback) GetFormat() OutputFormat
- func (fb *Feedback) OutputWriter() io.Writer
- func (fb *Feedback) Print(v interface{})
- func (fb *Feedback) PrintResult(res Result)
- func (fb *Feedback) Printf(format string, v ...interface{})
- func (fb *Feedback) SetErr(err io.Writer)
- func (fb *Feedback) SetFormat(f OutputFormat)
- func (fb *Feedback) SetOut(out io.Writer)
- type OutputFormat
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(v ...interface{})
Error behaves like fmt.Print but writes on the error writer and adds a newline. It also logs the error.
func ErrorWriter ¶
ErrorWriter is the same as OutputWriter but exposes the underlying error writer
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf behaves like fmt.Printf but writes on the error writer and adds a newline. It also logs the error.
func OutputWriter ¶
OutputWriter returns the underlying io.Writer to be used when the Print* api is not enough
func Print ¶
func Print(v interface{})
Print behaves like fmt.Print but writes on the out writer and adds a newline.
func PrintResult ¶
func PrintResult(res Result)
PrintResult is a convenient wrapper to provide feedback for complex data, where the contents can't be just serialized to JSON but requires more structure.
func Printf ¶
func Printf(format string, v ...interface{})
Printf behaves like fmt.Printf but writes on the out writer and adds a newline.
func SetDefaultFeedback ¶
func SetDefaultFeedback(f *Feedback)
SetDefaultFeedback lets callers override the default feedback object. Mostly useful for testing.
func SetFormat ¶
func SetFormat(f OutputFormat)
SetFormat can be used to change the output format at runtime
Types ¶
type Feedback ¶
type Feedback struct {
// contains filtered or unexported fields
}
Feedback wraps an io.Writer and provides an uniform API the CLI can use to provide feedback to the users.
func DefaultFeedback ¶
func DefaultFeedback() *Feedback
DefaultFeedback provides a basic feedback object to be used as default.
func New ¶
func New(out, err io.Writer, format OutputFormat) *Feedback
New creates a Feedback instance
func (*Feedback) Error ¶
func (fb *Feedback) Error(v ...interface{})
Error behaves like fmt.Print but writes on the error writer and adds a newline. It also logs the error.
func (*Feedback) ErrorWriter ¶
ErrorWriter is the same as OutputWriter but exposes the underlying error writer.
func (*Feedback) Errorf ¶
Errorf behaves like fmt.Printf but writes on the error writer and adds a newline. It also logs the error.
func (*Feedback) GetFormat ¶
func (fb *Feedback) GetFormat() OutputFormat
GetFormat returns the output format currently set
func (*Feedback) OutputWriter ¶
OutputWriter returns the underlying io.Writer to be used when the Print* api is not enough.
func (*Feedback) Print ¶
func (fb *Feedback) Print(v interface{})
Print behaves like fmt.Print but writes on the out writer and adds a newline.
func (*Feedback) PrintResult ¶
PrintResult is a convenient wrapper to provide feedback for complex data, where the contents can't be just serialized to JSON but requires more structure.
func (*Feedback) Printf ¶
Printf behaves like fmt.Printf but writes on the out writer and adds a newline.
func (*Feedback) SetFormat ¶
func (fb *Feedback) SetFormat(f OutputFormat)
SetFormat can be used to change the output format at runtime
type OutputFormat ¶
type OutputFormat int
OutputFormat is used to determine the output format
const ( // Text means plain text format, suitable for ansi terminals Text OutputFormat = iota // JSON means JSON format JSON // JSONMini is identical to JSON but without whitespaces JSONMini // YAML means YAML format YAML )