refactor(output): share the JSON, created-resource and batch tails

Mutations end with a.jsonResult or a.created instead of hand-rolled
--json branches, the two identical jsonResult/writeMutationJSON helpers
become one, and writeBatchJSON checks --json itself so batch commands
share one tail.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 10:43:46 +02:00
1 parent 27e39ec4be
commit 6b204a34c0
32 files changed
+87 -217

No files matched your search

+2 -8
View File
@@ -142,11 +142,8 @@ func (a *application) commentOn(cmd *cobra.Command, t target, n int64, kind refK
if err != nil {
return err
}
if a.options.json != "" {
return a.writeJSON(cmd, comment)
}
a.done(cmd, "Commented on %s", refLabel(t.Repo, n, item.Title))
return a.printURL(cmd, comment.URL)
return a.created(cmd, comment, comment.URL)
}
// lastComment returns the newest comment on n by the account tea acts as.
@@ -185,11 +182,8 @@ func (a *application) editComment(cmd *cobra.Command, t target, comment services
return err
}
edited.IssueNumber = comment.IssueNumber
if a.options.json != "" {
return a.writeJSON(cmd, edited)
}
a.done(cmd, "Edited %s", commentName(t, edited))
return nil
return a.jsonResult(cmd, edited)
}
// deleteComment deletes comment after a confirmation that defaults to no.