From 6892f3f36bfcad21d23b17345b718e44b269c1ef Mon Sep 17 00:00:00 2001 From: Hristo Georgiev Date: Thu, 15 Aug 2024 18:34:30 +0300 Subject: [PATCH] Add new output format to print each json object on a single line --- internal/output/output.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/output/output.go b/internal/output/output.go index f40d47a..8c13de8 100644 --- a/internal/output/output.go +++ b/internal/output/output.go @@ -64,6 +64,12 @@ func PrintObject(object interface{}, format string) error { return errors.Wrap(err, "unable to format json") } _, _ = fmt.Fprintln(IoStreams.Out, string(jsonString)) + } else if format == "json-raw" { + jsonString, err := json.Marshal(object) + if err != nil { + return errors.Wrap(err, "unable to format json") + } + _, _ = fmt.Fprintln(IoStreams.Out, string(jsonString)) } else if format != "none" { return errors.Errorf("unknown format: %v", format) }