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
@@ -617,11 +617,8 @@ $ tea run cancel 34 --force`,
if err != nil {
return err
}
if a.options.json != "" {
return a.writeJSON(cmd, run)
}
a.done(cmd, "Requested cancellation of run %d", id)
return nil
return a.jsonResult(cmd, run)
},
}
cmd.Flags().BoolVar(&force, "force", false, "Cancel without waiting for the runner to acknowledge")
@@ -678,11 +675,8 @@ $ tea run rerun 34 --job build`,
if run, err = service.Run(cmd.Context(), id); err != nil {
return err
}
if a.options.json != "" {
return a.writeJSON(cmd, run)
}
a.done(cmd, "Requested rerun of run %d (attempt %d); watch it with: tea run watch %d%s", id, run.Attempt, id, a.suggestedRepo(t))
return nil
return a.jsonResult(cmd, run)
},
}
cmd.Flags().BoolVar(&failed, "failed", false, "Rerun only the failed jobs")