Documentation
¶
Index ¶
- Constants
- Variables
- func Lenf(han string) (l int)
- func NewCompletionCmd(rootCmd *cobra.Command) (cmd *cobra.Command)
- func Pad(s, pad string, width int, align int) string
- func PadCenter(s, pad string, width int) string
- func PadLeft(s, pad string, width int) string
- func PadRight(s, pad string, width int) string
- func ReflectFieldValueAsString(v reflect.Value, field string) string
- type FormatOutput
- type OutputOption
- func (o *OutputOption) GetLine(obj reflect.Value) []string
- func (o *OutputOption) ListFilter(obj interface{}) interface{}
- func (o *OutputOption) Match(item reflect.Value) bool
- func (o *OutputOption) Output(obj interface{}) (data []byte, err error)
- func (o *OutputOption) OutputV2(obj interface{}) (err error)
- func (o *OutputOption) SetFlag(cmd *cobra.Command)
- func (o *OutputOption) SetFlagWithHeaders(cmd *cobra.Command, headers string)
- type RenderCell
- type Table
Constants ¶
const ( // JSONOutputFormat is the format of json JSONOutputFormat string = "json" // YAMLOutputFormat is the format of yaml YAMLOutputFormat string = "yaml" // TableOutputFormat is the format of table TableOutputFormat string = "table" )
const ( // AlignLeft align left AlignLeft = 0 // AlignCenter align center AlignCenter = 1 // AlignRight align right AlignRight = 2 )
Variables ¶
var ShellTypes = []string{
"zsh", "bash", "powerShell",
}
ShellTypes contains all types of shell
Functions ¶
func NewCompletionCmd ¶
NewCompletionCmd creates the completion command
Types ¶
type FormatOutput ¶
FormatOutput is the interface of format output
type OutputOption ¶
type OutputOption struct { Format string Columns string WithoutHeaders bool Filter []string Writer io.Writer CellRenderMap map[string]RenderCell }
OutputOption represent the format of output
func (*OutputOption) GetLine ¶
func (o *OutputOption) GetLine(obj reflect.Value) []string
GetLine returns the line of a table
func (*OutputOption) ListFilter ¶
func (o *OutputOption) ListFilter(obj interface{}) interface{}
ListFilter filter the data list by fields
func (*OutputOption) Match ¶
func (o *OutputOption) Match(item reflect.Value) bool
Match filter an item
func (*OutputOption) Output ¶
func (o *OutputOption) Output(obj interface{}) (data []byte, err error)
Output print the object into byte array Deprecated see also OutputV2
func (*OutputOption) OutputV2 ¶
func (o *OutputOption) OutputV2(obj interface{}) (err error)
OutputV2 print the data line by line
func (*OutputOption) SetFlag ¶
func (o *OutputOption) SetFlag(cmd *cobra.Command)
SetFlag set flag of output format Deprecated, see also SetFlagWithHeaders
func (*OutputOption) SetFlagWithHeaders ¶
func (o *OutputOption) SetFlagWithHeaders(cmd *cobra.Command, headers string)
SetFlagWithHeaders set the flags of output
type RenderCell ¶
RenderCell render a specific cell in a table
type Table ¶
type Table struct { Out io.Writer Rows [][]string ColumnWidths []int ColumnAlign []int Separator string WithHeader bool }
Table for console print
func CreateTableWithHeader ¶
CreateTableWithHeader init a table object
func (*Table) GetColumnAlign ¶
GetColumnAlign return the column alignment
func (*Table) SetColumnAlign ¶
SetColumnAlign sets the column alignment for the given column index
func (*Table) SetColumnsAligns ¶
SetColumnsAligns sets the alignment of the columns