MCPcopy Create free account
hub / github.com/cli/cli / Export

Method Export

pkg/cmd/discussion/client/types.go:188–218  ·  view source on GitHub ↗

Export returns the comment as a map for JSON output.

()

Source from the content-addressed store, hash-verified

186
187// Export returns the comment as a map for JSON output.
188func (c DiscussionComment) Export() map[string]interface{} {
189 replies := make([]interface{}, len(c.Replies.Comments))
190 for i, r := range c.Replies.Comments {
191 replies[i] = r.ExportReply()
192 }
193 reactions := make([]interface{}, len(c.ReactionGroups))
194 for i, rg := range c.ReactionGroups {
195 reactions[i] = rg.Export()
196 }
197 repliesMap := map[string]interface{}{
198 "totalCount": c.Replies.TotalCount,
199 "nodes": replies,
200 }
201 if c.Replies.Cursor != "" {
202 repliesMap["cursor"] = c.Replies.Cursor
203 }
204 if c.Replies.NextCursor != "" {
205 repliesMap["next"] = c.Replies.NextCursor
206 }
207 return map[string]interface{}{
208 "id": c.ID,
209 "url": c.URL,
210 "author": c.Author.Export(),
211 "body": c.Body,
212 "createdAt": c.CreatedAt,
213 "isAnswer": c.IsAnswer,
214 "upvoteCount": c.UpvoteCount,
215 "reactionGroups": reactions,
216 "replies": repliesMap,
217 }
218}
219
220// ExportReply returns a reply as a map for JSON output, without nested replies.
221func (c DiscussionComment) ExportReply() map[string]interface{} {

Callers

nothing calls this directly

Calls 2

ExportReplyMethod · 0.80
ExportMethod · 0.45

Tested by

no test coverage detected