From 21fa4480473c3d731cc6b302c76501056e84c9ec Mon Sep 17 00:00:00 2001
From: dlorenc <dlorenc@google.com>
Date: Sun, 22 Aug 2021 07:22:52 -0500
Subject: [PATCH] Cleanup the output of search (the text goes to stderr not
 stdout). (#421)

Fixes #420.

Signed-off-by: Dan Lorenc <dlorenc@google.com>
---
 cmd/rekor-cli/app/search.go | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/cmd/rekor-cli/app/search.go b/cmd/rekor-cli/app/search.go
index 2e73525..8fbb96e 100644
--- a/cmd/rekor-cli/app/search.go
+++ b/cmd/rekor-cli/app/search.go
@@ -44,14 +44,7 @@ type searchCmdOutput struct {
 }
 
 func (s *searchCmdOutput) String() string {
-	str := "No matching entries were found\n"
-	for i, uuid := range s.uuids {
-		if i == 0 {
-			str = "Found matching entries (listed by UUID):\n"
-		}
-		str += fmt.Sprintf("%v\n", uuid)
-	}
-	return str
+	return strings.Join(s.uuids, "\n") + "\n" // one extra /n to terminate the list
 }
 
 func addSearchPFlags(cmd *cobra.Command) error {
@@ -203,6 +196,8 @@ var searchCmd = &cobra.Command{
 			return nil, fmt.Errorf("no matching entries found")
 		}
 
+		fmt.Fprintln(os.Stderr, "Found matching entries (listed by UUID):")
+
 		return &searchCmdOutput{
 			uuids: resp.GetPayload(),
 		}, nil
-- 
GitLab