Fix sdlcli get -command result stdout write 86/7486/1 v0.9.3
authorTimo Tietavainen <timo.tietavainen@nokia.com>
Thu, 30 Dec 2021 10:40:57 +0000 (12:40 +0200)
committerTimo Tietavainen <timo.tietavainen@nokia.com>
Thu, 30 Dec 2021 14:34:42 +0000 (16:34 +0200)
Sdlcli get -command writes wrongly results to stderr stream. Fix sdlcli
get -command to write results to stdout stream when command execution
has succeeded. In addition add similar stdout redirect also to sdlcli
statistics -command just to keep the code look the same, even thought
there wasn't any real issue with sdlcli statistics -command's results
visibility.

Version: 0.9.3

Issue-Id: RIC-873

Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: Icc7d42d9200bdcc74bf1da6ceab341dd6b69c16e

docs/release-notes.rst
internal/cli/get.go
internal/cli/keys.go
internal/cli/statistics.go

index 6a1074b..c5bc735 100644 (file)
@@ -29,6 +29,10 @@ This document provides the release notes of the sdlgo.
 
 Version history
 ---------------
+[0.9.3] - 2021-12-30
+
+* Fix SDL CLI get -command to write results stdout stream when command success
+
 [0.9.2] - 2021-12-22
 
 * Fix SDL CLI healthcheck to ignore ghost Redis Sentinel entries
index f22ae73..f56c6a0 100644 (file)
@@ -59,7 +59,7 @@ Prints namespaces, keys or keys data in the given namespace.`
 )
 
 func newGetCmd(sdlCb SyncStorageCreateCb) *cobra.Command {
-       return &cobra.Command{
+       cmd := &cobra.Command{
                Use:     "get <namespace> <key> [<key2> <key3>... <keyN>]",
                Short:   "Display one or many resources",
                Long:    getLong,
@@ -78,6 +78,8 @@ func newGetCmd(sdlCb SyncStorageCreateCb) *cobra.Command {
                        return nil
                },
        }
+       cmd.SetOut(os.Stdout)
+       return cmd
 }
 
 func runGet(sdlCb SyncStorageCreateCb, args []string) (map[string]interface{}, error) {
index c656542..214dc97 100644 (file)
@@ -59,7 +59,7 @@ var (
 )
 
 func newKeysCmd(sdlCb SyncStorageCreateCb) *cobra.Command {
-       return &cobra.Command{
+       cmd := &cobra.Command{
                Use:     "keys <namespace> [pattern|default '*']",
                Short:   "List keys in the given namespace matching key search pattern",
                Long:    keysLong,
@@ -83,6 +83,8 @@ func newKeysCmd(sdlCb SyncStorageCreateCb) *cobra.Command {
                        return nil
                },
        }
+       cmd.SetOut(os.Stdout)
+       return cmd
 }
 
 func runListKeys(sdlCb SyncStorageCreateCb, args keysArgs) ([]string, error) {
index 05608e2..b247fc2 100644 (file)
@@ -43,7 +43,7 @@ var (
 )
 
 func newStatisticsCmd(dbCreateCb DbCreateCb) *cobra.Command {
-       return &cobra.Command{
+       cmd := &cobra.Command{
                Use:     "statistics",
                Short:   "Display statistics.",
                Long:    statsLong,
@@ -59,6 +59,8 @@ func newStatisticsCmd(dbCreateCb DbCreateCb) *cobra.Command {
                        return nil
                },
        }
+       cmd.SetOut(os.Stdout)
+       return cmd
 }
 
 func runStats(dbCreateCb DbCreateCb) ([]*sdlgoredis.DbStatistics, error) {