(ctx context.Context, u *ui.UI, comment *drive.Comment, includeAnchor, includeReplyDetails bool)
| 321 | } |
| 322 | |
| 323 | func writeDriveCommentDetail(ctx context.Context, u *ui.UI, comment *drive.Comment, includeAnchor, includeReplyDetails bool) error { |
| 324 | if outfmt.IsJSON(ctx) { |
| 325 | return outfmt.WriteJSON(ctx, stdoutWriter(ctx), map[string]any{"comment": comment}) |
| 326 | } |
| 327 | |
| 328 | u.Out().Linef("id\t%s", comment.Id) |
| 329 | if comment.Author != nil { |
| 330 | u.Out().Linef("author\t%s", comment.Author.DisplayName) |
| 331 | } |
| 332 | u.Out().Linef("content\t%s", comment.Content) |
| 333 | u.Out().Linef("created\t%s", comment.CreatedTime) |
| 334 | u.Out().Linef("modified\t%s", comment.ModifiedTime) |
| 335 | u.Out().Linef("resolved\t%t", comment.Resolved) |
| 336 | if comment.QuotedFileContent != nil && comment.QuotedFileContent.Value != "" { |
| 337 | u.Out().Linef("quoted\t%s", comment.QuotedFileContent.Value) |
| 338 | } |
| 339 | if includeAnchor && strings.TrimSpace(comment.Anchor) != "" { |
| 340 | u.Out().Linef("anchor\t%s", comment.Anchor) |
| 341 | } |
| 342 | if len(comment.Replies) > 0 { |
| 343 | u.Out().Linef("replies\t%d", len(comment.Replies)) |
| 344 | } |
| 345 | if includeReplyDetails { |
| 346 | for _, reply := range comment.Replies { |
| 347 | if reply == nil { |
| 348 | continue |
| 349 | } |
| 350 | author := "" |
| 351 | if reply.Author != nil { |
| 352 | author = reply.Author.DisplayName |
| 353 | } |
| 354 | action := "" |
| 355 | if strings.TrimSpace(reply.Action) != "" { |
| 356 | action = reply.Action |
| 357 | } |
| 358 | u.Out().Linef(" reply\t%s\t%s\t%s\t%s", reply.Id, author, truncateString(reply.Content, 60), action) |
| 359 | } |
| 360 | } |
| 361 | return nil |
| 362 | } |
| 363 | |
| 364 | func createDriveComment(ctx context.Context, svc *drive.Service, fileID, content, quoted, anchor string) (*drive.Comment, error) { |
| 365 | comment := &drive.Comment{Content: content} |
no test coverage detected