utility

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package utility provides utility functionality that is used throughout the Civo CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskForConfirm added in v0.1.2

func AskForConfirm(message string) error

AskForConfirm parses and verifies user input for confirmation.

func AskForConfirmDelete added in v0.1.2

func AskForConfirmDelete(resourceType string) error

AskForConfirmDelete builds a message to ask the user to confirm delete a resource and then sends it through to AskForConfirm to parses and verifies user input.

func BoolToYesNo

func BoolToYesNo(d bool) string

BoolToYesNo returns Yes or No depending on the value of a boolean This wouldn't be as necessary if Go had a ternary operator

func ColorStatus added in v0.1.2

func ColorStatus(status string) interface{}

func Error added in v0.1.2

func Error(msg string, args ...interface{})

func GetStringMap added in v0.1.2

func GetStringMap(s string) map[string]string

getStringMap convert string in the format a:1,b:2,c:3 in map[string]string, this is util for the flags StringArrayVarP

func Green added in v0.1.2

func Green(value string) string

func ObtainKubeConfig added in v0.1.2

func ObtainKubeConfig(localKubeconfig string, civoConfig string, merge bool) error

func Red added in v0.1.2

func Red(value string) string

func RedConfirm added in v0.1.5

func RedConfirm(msg string, args ...interface{})

func YellowConfirm added in v0.1.2

func YellowConfirm(msg string, args ...interface{})

Types

type OutputWriter

type OutputWriter struct {
	Keys       []string
	Labels     []string
	Values     [][]string
	TempValues []string
}

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) WriteHeader added in v0.1.2

func (ow *OutputWriter) WriteHeader(label string)

WriteSubheader writes a centred heading line in to output

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

Jump to

Keyboard shortcuts

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