Documentation
¶
Overview ¶
Package utility provides utility functionality that is used throughout the Civo CLI.
Index ¶
- func BoolToYesNo(d bool) string
- type OutputWriter
- func (ow *OutputWriter) AppendData(key, value string)
- func (ow *OutputWriter) AppendDataWithLabel(key, value, label string)
- func (ow *OutputWriter) StartLine()
- func (ow *OutputWriter) WriteCustomOutput(fields string)
- func (ow *OutputWriter) WriteKeyValues()
- func (ow *OutputWriter) WriteMultipleObjectsJSON()
- func (ow *OutputWriter) WriteSingleObjectJSON()
- func (ow *OutputWriter) WriteSubheader(label string)
- func (ow *OutputWriter) WriteTable()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolToYesNo ¶
BoolToYesNo returns Yes or No depending on the value of a boolean This wouldn't be as necessary if Go had a ternary operator
Types ¶
type OutputWriter ¶
OutputWriter is for printing structured data in various tabular formats
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendData("ID", instance.ID)
# Then one of:
ow.WriteSingleObjectJSON()
ow.WriteMultipleObjectsJSON()
ow.WriteCustomOutput(OutputFields)
ow.WriteKeyValues()
ow.WriteTable()
func NewOutputWriter ¶
func NewOutputWriter() *OutputWriter
NewOutputWriter builds a new OutputWriter
func NewOutputWriterWithMap ¶
func NewOutputWriterWithMap(data map[string]string) *OutputWriter
NewOutputWriterWithMap builds a new OutputWriter and automatically inserts the supplied map as a single line
func (*OutputWriter) AppendData ¶
func (ow *OutputWriter) AppendData(key, value string)
AppendData adds a line of data to the output writer
func (*OutputWriter) AppendDataWithLabel ¶
func (ow *OutputWriter) AppendDataWithLabel(key, value, label string)
AppendDataWithLabel adds a line of data to the output writer
func (*OutputWriter) StartLine ¶
func (ow *OutputWriter) StartLine()
StartLine starts a new line of output
func (*OutputWriter) WriteCustomOutput ¶
func (ow *OutputWriter) WriteCustomOutput(fields string)
WriteCustomOutput prints one or multiple objects using custom formatting
func (*OutputWriter) WriteKeyValues ¶
func (ow *OutputWriter) WriteKeyValues()
WriteKeyValues prints a single object stored in the OutputWriter in key: value format
func (*OutputWriter) WriteMultipleObjectsJSON ¶
func (ow *OutputWriter) WriteMultipleObjectsJSON()
WriteMultipleObjectsJSON writes the JSON for multiple objects to STDOUT
func (*OutputWriter) WriteSingleObjectJSON ¶
func (ow *OutputWriter) WriteSingleObjectJSON()
WriteSingleObjectJSON writes the JSON for a single object to STDOUT
func (*OutputWriter) WriteSubheader ¶
func (ow *OutputWriter) WriteSubheader(label string)
WriteSubheader writes a centred heading line in to output
func (*OutputWriter) WriteTable ¶
func (ow *OutputWriter) WriteTable()
WriteTable prints multiple objects stored in the OutputWriter in tabular format