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:
bircni committed 2026-10-11 22:57:38 +02:00
1 parent 04d5f2aed0
commit 48a188ceac
4 files changed
+17 -8

No files matched your search

+8
View File
@@ -15,6 +15,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"regexp"
"strings"
"testing"
@@ -291,3 +292,10 @@ func selectablesHandler(t *testing.T, push bool, next http.HandlerFunc) http.Han
}
}
}
var ansiSequence = regexp.MustCompile("\x1b\\[[0-9;]*m")
// withoutANSI drops SGR color sequences, such as those in pretty JSON on a terminal.
func withoutANSI(s string) string {
return ansiSequence.ReplaceAllString(s, "")
}