Skip to content

Commit

Permalink
Merge pull request #213 from gotha/feat/output-json-raw
Browse files Browse the repository at this point in the history
Add new output format to print each json object on a single line
  • Loading branch information
d-rk authored Nov 28, 2024
2 parents 0701ca8 + 6892f3f commit a787606
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit a787606

Please sign in to comment.