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
@@ -50,11 +50,8 @@ $ tea milestone %[1]s v1.0 v1.1`, verb), Annotations: map[string]string{"tea.arg
a.done(cmd, "%s %s", past, milestoneName(t, item))
}
return item, err
}, func(services.Milestone) {})
if a.options.json != "" {
failures = append(failures, writeBatchJSON(a, cmd, len(selected), results))
}
return errors.Join(failures...)
}, nil)
return errors.Join(append(failures, writeBatchJSON(a, cmd, len(selected), results))...)
}}
cmd.Flags().BoolVar(&byName, "by-name", false, "Match numeric arguments as milestone titles rather than IDs")
cmd.ValidArgsFunction = a.completeMilestoneArgs(true)