From 6759526a46869b7479d0fe4e90c703e8096e89c9 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 31 Jul 2024 17:09:43 -0400 Subject: [PATCH] fix: list operations - domains,objects - print ndjson lines. --- CHANGELOG.md | 3 +++ pkg/cmd/operations.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d625fce..02de3cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - 2024-05-30 +### Added +- For REST operations that return lists, print newline-separated JSON objects (ndjson) + ## [0.0.1] - 2024-05-30 ### Added diff --git a/pkg/cmd/operations.go b/pkg/cmd/operations.go index 2ed51a0..5186c7a 100644 --- a/pkg/cmd/operations.go +++ b/pkg/cmd/operations.go @@ -35,7 +35,10 @@ var domainsCmd = &cobra.Command{ c := newClient() ok, err := c.Operations.GetDomains(&operations.GetDomainsParams{}) check(err) - NewPrinter(output.String(), os.Stdout)(ok.Payload) + p := NewPrinter(output.String(), os.Stdout) + for _, v := range ok.Payload { + p(v) + } }, } @@ -50,7 +53,10 @@ var ( c := newClient() ok, err := c.Operations.GetObjects(&operations.GetObjectsParams{Query: args[0]}) check(err) - NewPrinter(output.String(), os.Stdout)(ok.Payload) + p := NewPrinter(output.String(), os.Stdout) + for _, v := range ok.Payload { + p(v) + } }, } )