MCPcopy Create free account
hub / github.com/openclaw/gogcli / writeDocsTableRowActionResult

Function writeDocsTableRowActionResult

internal/cmd/docs_table_row_style.go:120–162  ·  view source on GitHub ↗
(
	ctx context.Context,
	docID, tabID, action, valueName string,
	results []docsTableRowActionResult,
)

Source from the content-addressed store, hash-verified

118}
119
120func writeDocsTableRowActionResult(
121 ctx context.Context,
122 docID, tabID, action, valueName string,
123 results []docsTableRowActionResult,
124) error {
125 sort.Slice(results, func(i, j int) bool {
126 return results[i].TableIndex < results[j].TableIndex
127 })
128 tables := make([]map[string]any, 0, len(results))
129 for _, result := range results {
130 tables = append(tables, map[string]any{"tableIndex": result.TableIndex, valueName: result.Value})
131 }
132 if outfmt.IsJSON(ctx) {
133 payload := map[string]any{
134 "documentId": docID,
135 "action": action,
136 "target": "row",
137 "updated": true,
138 "tables": tables,
139 }
140 if len(results) == 1 {
141 payload["tableIndex"] = results[0].TableIndex
142 payload[valueName] = results[0].Value
143 }
144 if tabID != "" {
145 payload["tabId"] = tabID
146 }
147 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), payload)
148 }
149
150 u := ui.FromContext(ctx)
151 u.Out().Linef("documentId\t%s", docID)
152 u.Out().Linef("action\t%s", action)
153 u.Out().Linef("target\trow")
154 for _, result := range results {
155 u.Out().Linef("table\t%d\t%s\t%v", result.TableIndex, valueName, result.Value)
156 }
157 u.Out().Linef("updated\ttrue")
158 if tabID != "" {
159 u.Out().Linef("tabId\t%s", tabID)
160 }
161 return nil
162}

Callers 2

RunMethod · 0.85
RunMethod · 0.85

Calls 6

IsJSONFunction · 0.92
WriteJSONFunction · 0.92
FromContextFunction · 0.92
stdoutWriterFunction · 0.85
LinefMethod · 0.80
OutMethod · 0.80

Tested by

no test coverage detected