output

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package output contains helper utility to build and format the output

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStrings

func FormatStrings() string

FormatStrings returns a string representing all output formats. this is useful for help text / flag info

func Get

func Get() []string

Get returns available output formats

func Has

func Has(format string) bool

Has returns true if the list of available output formats contains the provided string, false if not

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is used to prepare the output. It internally create a Formatter and use it to print the 'object' to different formats and colors (based on the flags)

func NewBuilder

func NewBuilder(format string) *Builder

NewBuilder returns a new output.Builder with desired format and colored output

func (*Builder) Build

func (b *Builder) Build(fn func(*Formatter) error) error

Build builds the callback function to be used directly in cobra.Command in order not to pass around private structs from go-cloudca library

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter is used to format retrieved object to selected format and print it out on STDOUT and also colorized it if the flag is set.

func (*Formatter) Format

func (f *Formatter) Format(object interface{}) error

Format prints the representation of input 'object' to STDOUT based on the requested 'format' (JSON or YAML). The output will also be colorized if flag is set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL