MCPcopy Create free account
hub / github.com/GetStream/stream-cli / printUIObject

Function printUIObject

pkg/utils/printer.go:40–68  ·  view source on GitHub ↗
(cmd *cobra.Command, object interface{})

Source from the content-addressed store, hash-verified

38}
39
40func printUIObject(cmd *cobra.Command, object interface{}) error {
41 var asMap map[string]interface{}
42 b, err := json.Marshal(object)
43 if err != nil {
44 return err
45 }
46 err = json.Unmarshal(b, &asMap)
47 if err != nil {
48 return err
49 }
50
51 _, ok := asMap["ratelimit"]
52 if ok {
53 delete(asMap, "ratelimit")
54 }
55
56 rootNode := &widgets.TreeNode{Nodes: []*widgets.TreeNode{}}
57 for k, v := range asMap {
58 addNodesRecursive(rootNode, k+": ", v)
59 }
60
61 if err := ui.Init(); err != nil {
62 return err
63 }
64 defer ui.Close()
65
66 renderUI(rootNode)
67 return nil
68}
69
70type nodeValue string
71

Callers 1

PrintObjectFunction · 0.85

Calls 2

addNodesRecursiveFunction · 0.85
renderUIFunction · 0.85

Tested by

no test coverage detected