-
Notifications
You must be signed in to change notification settings - Fork 3
/
category.go
58 lines (47 loc) · 1.1 KB
/
category.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package displayers
import (
"io"
"strconv"
"strings"
"github.com/tecbiz-ch/nutanix-go-sdk/schema"
)
// Categories wraps a nutanix CategoryKeyList.
type Categories struct {
schema.CategoryKeyList
}
//var _ Displayable = &Categories{}
func (o Categories) JSON(w io.Writer) error {
return displayJSON(w, o.Entities)
}
func (o Categories) JSONPath(w io.Writer, template string) error {
return displayJSONPath(w, template, o.Entities)
}
func (o Categories) PP(w io.Writer) error {
return displayPP(w, o.Entities)
}
func (o Categories) YAML(w io.Writer) error {
return displayYAML(w, o.Entities)
}
func (o Categories) header() []string {
return []string{
"Name",
"Description",
"SystemDefined",
"Values",
}
}
func (o Categories) TableData(w io.Writer) error {
data := make([][]string, len(o.Entities))
for i, category := range o.Entities {
data[i] = []string{
category.Name,
category.Description,
strconv.FormatBool(category.SystemDefined),
strings.Join(category.Values, ","),
}
}
return displayTable(w, data, o.header())
}
func (o Categories) Text(w io.Writer) error {
return nil
}