Documentation
¶
Index ¶
Constants ¶
View Source
const ( // ItemMap parsed from map, struct ItemMap = "map" // ItemList parsed from array, slice ItemList = "list" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
// Val string
Key string
// contains filtered or unexported fields
}
Item definition
type Items ¶
type Items struct {
List []*Item
// contains filtered or unexported fields
}
Items definition
type List ¶
type List struct {
showcom.Base // use for internal
// options
Opts *Options
// contains filtered or unexported fields
}
List definition. data allow type: struct, slice, array, map
String len:
len("你好"), len("hello"), len("hello你好") -> 6 5 11
func NewList ¶
func NewList(title string, data any, fns ...OptionFunc) *List
NewList instance.
data type allow: struct, slice, array, map
func (*List) WithOptionFns ¶
func (l *List) WithOptionFns(fns []OptionFunc) *List
WithOptionFns with options func
func (*List) WithOptions ¶
func (l *List) WithOptions(fns ...OptionFunc) *List
WithOptions with options func
type ListOpFunc ¶
type ListOpFunc = OptionFunc
type Lists ¶
type Lists struct {
showcom.Base // use for internal
// options
Opts *Options
// contains filtered or unexported fields
}
Lists use for formatting and printing multi list data
func NewLists ¶
func NewLists(mList any, fns ...OptionFunc) *Lists
NewLists create lists. allow: map[string]any, struct-ptr
func (*Lists) AddSublist ¶
AddSublist with options func list
func (*Lists) WithOptionFns ¶
func (ls *Lists) WithOptionFns(fns []OptionFunc) *Lists
WithOptionFns with options func
func (*Lists) WithOptions ¶
func (ls *Lists) WithOptions(fns ...OptionFunc) *Lists
WithOptions with an options func list
type Options ¶
type Options struct {
// IgnoreEmpty ignore empty value item. default: true
IgnoreEmpty bool
// UpperFirst upper first char for the item.value. default: false
UpperFirst bool
SepChar string // split key value
LeftIndent string
KeyWidth int // if not set, will be auto-detected.
KeyMinWidth int
KeyStyle string
ValueStyle string
TitleStyle string
// FilterFunc filter item.
// - return true to show item, otherwise hide item.
FilterFunc func(item *Item) bool
}
Options for List, Lists
Click to show internal directories.
Click to hide internal directories.