fix subscribe command printing in case format is textprot and --quiet is used
@@ -232,11 +232,18 @@ func subRequest(ctx context.Context,
}
if !viper.GetBool("quiet") {
buff := new(bytes.Buffer)
+ if viper.GetString("format") == "textproto" {
+ _, err = buff.Write(b)
+ if err != nil {
+ logger.Printf("failed to write msg: err=%v, msg=%s", err, string(b))
+ }
+ } else {
err = json.Indent(buff, b, "", " ")
if err != nil {
logger.Printf("failed to indent msg: err=%v, msg=%s", err, string(b))
return
}
+ }
lock.Lock()
fmt.Println(buff.String())
lock.Unlock()
@@ -277,11 +284,18 @@ func subRequest(ctx context.Context,
continue
}
buff := new(bytes.Buffer)
+ if viper.GetString("format") == "textproto" {
+ _, err = buff.Write(b)
+ if err != nil {
+ logger.Printf("failed to write msg: err=%v, msg=%s", err, string(b))
+ }
+ } else {
err = json.Indent(buff, b, "", " ")
if err != nil {
logger.Printf("failed to indent msg: err=%v : msg=%s", err, string(b))
return
}
+ }
fmt.Println(buff.String())
case *gnmi.SubscribeResponse_SyncResponse:
fmt.Printf("sync response from %s: %+v\n", target.Address, resp.SyncResponse)
