Documentation ¶
Index ¶
- func DescribeObject(v interface{}) error
- func ExitIfErr(err error)
- func FormatOutput(v interface{}, outputFormat string) (string, string, error)
- func StringInSlice(s []string, v string) bool
- func StringPointer(s string) *string
- func WriteOutput(v interface{}, caption string, populateTable func(*tablewriter.Table)) error
- type IOStreams
- func (ios IOStreams) WriteBytes(b []byte) (int, error)
- func (ios IOStreams) WriteBytesln(b []byte)
- func (ios IOStreams) WriteErrorBytes(b []byte) (int, error)
- func (ios IOStreams) WriteErrorNewline() error
- func (ios IOStreams) WriteErrorString(s string) error
- func (ios IOStreams) WriteNewline() error
- func (ios IOStreams) WriteOutput(v interface{}, o *PrinterOptions) error
- func (ios IOStreams) WriteString(s string) error
- func (ios IOStreams) WriteStringf(format string, a ...interface{}) error
- func (ios IOStreams) WriteStringln(a ...interface{}) error
- type PrinterOptions
- func (o *PrinterOptions) AddPrinterFlags(c *cobra.Command)
- func (o *PrinterOptions) FormatCategory() string
- func (o *PrinterOptions) FormatOutput(v interface{}) (string, string, error)
- func (o *PrinterOptions) ParseOutput(in []byte, v interface{}) error
- func (o *PrinterOptions) SupportedFormatCategories() []string
- func (o *PrinterOptions) SupportedFormats() []string
- func (o *PrinterOptions) Validate() error
- func (o *PrinterOptions) WithDefaultOutput(output string) *PrinterOptions
- func (o *PrinterOptions) WithDefaultTableWriter() *PrinterOptions
- func (o *PrinterOptions) WithItemsSelector(selectItems func() interface{}) *PrinterOptions
- func (o *PrinterOptions) WithTableWriter(caption string, populateTable func(*tablewriter.Table)) *PrinterOptions
- func (o *PrinterOptions) WriteOutput(v interface{}) error
- type ProjectedDateValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DescribeObject ¶
func DescribeObject(v interface{}) error
DescribeObject writes a single object in the default format with default printer options retained for backwards compat with verb-noun commands which assume STDOUT
func FormatOutput ¶
FormatOutput writes a single object in the configured format
func StringInSlice ¶
func StringPointer ¶
func WriteOutput ¶
func WriteOutput(v interface{}, caption string, populateTable func(*tablewriter.Table)) error
WriteOutput writes output in the configured format with default printer options retained for backwards compat with verb-noun commands which assume STDOUT
Types ¶
type IOStreams ¶
type IOStreams struct { // In think, os.Stdin In io.Reader // Out think, os.Stdout Out io.Writer // ErrOut think, os.Stderr ErrOut io.Writer }
IOStreams provides the standard names for iostreams. This is useful for embedding and for unit testing. Inconsistent and different names make it hard to read and review code
func DefaultOSStreams ¶
func DefaultOSStreams() IOStreams
DefaultOSStreams returns a valid IOStreams pointing at os.Stdin, os.Stdout, os.Stderr
func NewTestIOStreams ¶
NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests
func (IOStreams) WriteBytes ¶
WriteBytes writes a byte array to o.Out
func (IOStreams) WriteBytesln ¶
WriteBytesln writes a byte array to o.Out
func (IOStreams) WriteErrorBytes ¶
WriteErrorBytes writes a string to o.ErrOut
func (IOStreams) WriteErrorNewline ¶
WriteErrorNewline writes a newline to o.ErrOut
func (IOStreams) WriteErrorString ¶
WriteErrorString writes a string to o.ErrOut
func (IOStreams) WriteNewline ¶
WriteNewline writes a newline to o.Out
func (IOStreams) WriteOutput ¶
func (ios IOStreams) WriteOutput(v interface{}, o *PrinterOptions) error
WriteOutput writes output to s.Out in the configured format
func (IOStreams) WriteString ¶
WriteString writes a string to o.Out
func (IOStreams) WriteStringf ¶
WriteStringf writes a string to o.Out
func (IOStreams) WriteStringln ¶
WriteStringln writes a string to o.Out with a newline
type PrinterOptions ¶
type PrinterOptions struct { OutputFormat *string DefaultOutputFormat *string Caption *string PopulateTable *func(*tablewriter.Table) ItemsSelector *func() interface{} }
PrinterOptions contains options for printing
func NewPrinterOptions ¶
func NewPrinterOptions() *PrinterOptions
NewPrinterOptions defines new printer options
func (*PrinterOptions) AddPrinterFlags ¶
func (o *PrinterOptions) AddPrinterFlags(c *cobra.Command)
AddPrinterFlags adds flags to a cobra.Command
func (*PrinterOptions) FormatCategory ¶
func (o *PrinterOptions) FormatCategory() string
FormatCategory returns the dereferenced format category
func (*PrinterOptions) FormatOutput ¶
func (o *PrinterOptions) FormatOutput(v interface{}) (string, string, error)
FormatOutput writes a single object in the configured format
func (*PrinterOptions) ParseOutput ¶
func (o *PrinterOptions) ParseOutput(in []byte, v interface{}) error
ParseOutput reads a single object in the configured format
func (*PrinterOptions) SupportedFormatCategories ¶
func (o *PrinterOptions) SupportedFormatCategories() []string
SupportedFormatCategories returns the list of supported formats
func (*PrinterOptions) SupportedFormats ¶
func (o *PrinterOptions) SupportedFormats() []string
SupportedFormats returns the list of supported formats
func (*PrinterOptions) Validate ¶
func (o *PrinterOptions) Validate() error
Validate asserts that the printer options are valid
func (*PrinterOptions) WithDefaultOutput ¶
func (o *PrinterOptions) WithDefaultOutput(output string) *PrinterOptions
WithDefaultOutput sets a default output format if one is not provided through a flag value
func (*PrinterOptions) WithDefaultTableWriter ¶
func (o *PrinterOptions) WithDefaultTableWriter() *PrinterOptions
WithDefaultTableWriter sets a default table writer
func (*PrinterOptions) WithItemsSelector ¶
func (o *PrinterOptions) WithItemsSelector(selectItems func() interface{}) *PrinterOptions
func (*PrinterOptions) WithTableWriter ¶
func (o *PrinterOptions) WithTableWriter(caption string, populateTable func(*tablewriter.Table)) *PrinterOptions
WithTableWriter decorates a PrinterOptions with table writer configuration
func (*PrinterOptions) WriteOutput ¶
func (o *PrinterOptions) WriteOutput(v interface{}) error
WriteOutput writes output in the configured format
type ProjectedDateValue ¶
func NewProjectedDate ¶
func NewProjectedDate() *ProjectedDateValue
NewProjectedDate creates a new instance of a ProjectedDateValue, allocating memory for both properties which can then be set using the Value pattern
func (ProjectedDateValue) Set ¶
func (v ProjectedDateValue) Set(s string) error
Set implements pflag.Value
func (ProjectedDateValue) Type ¶
func (v ProjectedDateValue) Type() string
Type implements pflag.Value