Skip to content

Commit

Permalink
Add new output format to print each json object on a single line
Browse files Browse the repository at this point in the history
  • Loading branch information
gotha committed Aug 15, 2024
1 parent 293ab5c commit 6892f3f
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 6892f3f

Please sign in to comment.