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

Method writeResult

internal/cmd/docs_format.go:357–392  ·  view source on GitHub ↗
(ctx context.Context, resp *docs.BatchUpdateDocumentResponse, requestCount, rangeCount int, target docsRequestTarget)

Source from the content-addressed store, hash-verified

355}
356
357func (c *DocsFormatCmd) writeResult(ctx context.Context, resp *docs.BatchUpdateDocumentResponse, requestCount, rangeCount int, target docsRequestTarget) error {
358 u := ui.FromContext(ctx)
359 if outfmt.IsJSON(ctx) {
360 payload := map[string]any{
361 "documentId": resp.DocumentId,
362 "requests": requestCount,
363 "ranges": rangeCount,
364 }
365 if target.TabID != "" {
366 payload["tabId"] = target.TabID
367 }
368 if target.SegmentID != "" {
369 payload["segmentId"] = target.SegmentID
370 payload["segmentType"] = target.SegmentKind
371 }
372 if resp.WriteControl != nil {
373 payload["writeControl"] = resp.WriteControl
374 }
375 return outfmt.WriteJSON(ctx, stdoutWriter(ctx), payload)
376 }
377
378 u.Out().Linef("id\t%s", resp.DocumentId)
379 u.Out().Linef("requests\t%d", requestCount)
380 u.Out().Linef("ranges\t%d", rangeCount)
381 if target.TabID != "" {
382 u.Out().Linef("tabId\t%s", target.TabID)
383 }
384 if target.SegmentID != "" {
385 u.Out().Linef("segmentId\t%s", target.SegmentID)
386 u.Out().Linef("segmentType\t%s", target.SegmentKind)
387 }
388 if resp.WriteControl != nil && resp.WriteControl.RequiredRevisionId != "" {
389 u.Out().Linef("revision\t%s", resp.WriteControl.RequiredRevisionId)
390 }
391 return nil
392}
393
394func (f DocsFormatFlags) any() bool {
395 return f.options().Any()

Callers 1

RunMethod · 0.95

Calls 6

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

Tested by

no test coverage detected