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
@@ -300,12 +300,7 @@ $ tea release create v1.1.0-rc1 --target release/1.1 --draft --prerelease --titl
|
||||
item.Assets = append(item.Assets, asset)
|
||||
a.done(cmd, "Uploaded %s (%s)", asset.Name, terminal.Bytes(asset.Size))
|
||||
}
|
||||
if a.options.json != "" {
|
||||
failures = append(failures, a.writeJSON(cmd, item))
|
||||
} else {
|
||||
failures = append(failures, a.printURL(cmd, item.URL))
|
||||
}
|
||||
return errors.Join(failures...)
|
||||
return errors.Join(append(failures, a.created(cmd, item, item.URL))...)
|
||||
},
|
||||
}
|
||||
fields.register(a, command)
|
||||
@@ -402,11 +397,8 @@ func (a *application) releasePublishCommand() *cobra.Command {
|
||||
a.done(cmd, "Published release %s in %s", item.Tag, target.Repo)
|
||||
}
|
||||
return item, err
|
||||
}, func(services.Release) {})
|
||||
if a.options.json != "" {
|
||||
failures = append(failures, writeBatchJSON(a, cmd, len(args), results))
|
||||
}
|
||||
return errors.Join(failures...)
|
||||
}, nil)
|
||||
return errors.Join(append(failures, writeBatchJSON(a, cmd, len(args), results))...)
|
||||
},
|
||||
}
|
||||
command.ValidArgsFunction = a.completeReleases()
|
||||
|
||||
Reference in new issue
Block a user