(ctx context.Context, resp *docs.BatchUpdateDocumentResponse, requestCount, rangeCount int, target docsRequestTarget)
| 355 | } |
| 356 | |
| 357 | func (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 | |
| 394 | func (f DocsFormatFlags) any() bool { |
| 395 | return f.options().Any() |
no test coverage detected