mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
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:
32 files changed
+87
-217
No files matched your search
@@ -268,13 +268,10 @@ func ownReview(pull services.Pull, t target, state string) error {
|
||||
// reportReview reports a submitted review, then prints its URL, or the review as JSON.
|
||||
func (a *application) reportReview(cmd *cobra.Command, t target, pull services.Pull, item services.Review) error {
|
||||
a.done(cmd, "%s pull request %s", reviewVerbs[item.State], refLabel(t.Repo, pull.Number, pull.Title))
|
||||
switch {
|
||||
case a.options.json != "":
|
||||
return a.writeJSON(cmd, item)
|
||||
case item.URL != "":
|
||||
return a.printURL(cmd, item.URL)
|
||||
if a.options.json == "" && item.URL == "" {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
return a.created(cmd, item, item.URL)
|
||||
}
|
||||
|
||||
// readInlineComments reads the inline comments of --comments-file, a JSON array.
|
||||
@@ -625,10 +622,7 @@ func (a *application) pullReviewReplyCommand() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
a.done(cmd, "Replied to review comment %d on %s#%d", id, t.Repo, n)
|
||||
if a.options.json != "" {
|
||||
return a.writeJSON(cmd, item)
|
||||
}
|
||||
return a.printURL(cmd, item.URL)
|
||||
return a.created(cmd, item, item.URL)
|
||||
}}
|
||||
cmd.Flags().StringVarP(&body, "body", "b", "", "Reply body")
|
||||
cmd.Flags().StringVarP(&file, "body-file", "F", "", "Read the body from `file`, or - for stdin")
|
||||
|
||||
Reference in new issue
Block a user