mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(app): pretty-print JSON on a terminal and reconcile the foundation streams
writeJSON uses the indented, colored JSON writer when stdout is a terminal. Help and JSON tests now expect the -L shorthand column and compare terminal JSON without color sequences. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
4 files changed
+17
-8
No files matched your search
@@ -55,7 +55,8 @@ func (a *application) writeHuman(cmd *cobra.Command, text string) error {
|
||||
|
||||
// writeJSON writes v as JSON, filtered by --json fields and --jq.
|
||||
func (a *application) writeJSON(cmd *cobra.Command, v any) error {
|
||||
return terminal.WriteJSON(cmd.OutOrStdout(), v, a.options.json, a.options.jq)
|
||||
pretty := a.deps.Streams.OutTTY
|
||||
return terminal.JSONOutput{Fields: a.options.json, Query: a.options.jq, Pretty: pretty, Color: pretty && a.colorEnabled()}.Write(cmd.OutOrStdout(), v)
|
||||
}
|
||||
|
||||
// listSpec describes how a list command shows its items to people.
|
||||
|
||||
Reference in new issue
Block a user