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 -5
View File
@@ -66,7 +66,7 @@ $ tea milestone issue %[1]s v1.0 12 13 '#14'`, verb), Annotations: map[string]st
item, err = service.Edit(cmd.Context(), n, services.IssueEdit{Milestone: &milestone.ID})
}
return item, itemError(err, target.Repo)
}, func(services.Issue) {})
}, nil)
if len(results) > 0 {
changed := make([]string, len(results))
for i, item := range results {
@@ -74,10 +74,7 @@ $ tea milestone issue %[1]s v1.0 12 13 '#14'`, verb), Annotations: map[string]st
}
a.done(cmd, "%s %s %s %s", past, strings.Join(changed, ", "), preposition, milestoneName(target, milestone))
}
if a.options.json != "" {
failures = append(failures, writeBatchJSON(a, cmd, len(numbers), results))
}
return errors.Join(failures...)
return errors.Join(append(failures, writeBatchJSON(a, cmd, len(numbers), results))...)
}}
command.Flags().BoolVar(&byName, "by-name", false, "Match a numeric milestone argument as a title rather than an ID")
milestones, issues := a.completeMilestones(), a.completeIssues("open")