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

Function addNodesRecursive

pkg/utils/printer.go:76–103  ·  view source on GitHub ↗
(parentNode *widgets.TreeNode, prefix string, value interface{})

Source from the content-addressed store, hash-verified

74}
75
76func addNodesRecursive(parentNode *widgets.TreeNode, prefix string, value interface{}) {
77 node := &widgets.TreeNode{Value: nodeValue(prefix), Nodes: []*widgets.TreeNode{}}
78
79 switch v := value.(type) {
80 case map[string]interface{}:
81 for k, val := range v {
82 addNodesRecursive(node, k+": ", val)
83 }
84 case []interface{}:
85 for i, v := range v {
86 addNodesRecursive(node, fmt.Sprintf("[%v] ", i), v)
87 }
88 case bool:
89 node = &widgets.TreeNode{Value: nodeValue(prefix + strconv.FormatBool(v))}
90 case string:
91 if v == "" {
92 v = "\"\""
93 }
94
95 node = &widgets.TreeNode{Value: nodeValue(prefix + v)}
96 case float64:
97 node = &widgets.TreeNode{Value: nodeValue(prefix + strconv.FormatFloat(v, 'f', -1, 64))}
98 default:
99 node = &widgets.TreeNode{Value: nodeValue(prefix + "null")}
100 }
101
102 parentNode.Nodes = append(parentNode.Nodes, node)
103}
104
105func renderUI(rootNode *widgets.TreeNode) {
106 // First section: instructions

Callers 1

printUIObjectFunction · 0.85

Calls 1

nodeValueTypeAlias · 0.85

Tested by

no test coverage detected