Skip to content

Commit

Permalink
Use EmitUnpopulated so that kaspactl prints all fields, even the defa…
Browse files Browse the repository at this point in the history
…ult ones (#1561)

Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
  • Loading branch information
svarogg and elichai authored Mar 1, 2021
1 parent 103edf9 commit df19bdf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/kaspactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"fmt"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"
"os"
"time"

"github.com/kaspanet/kaspad/infrastructure/network/netadapter/server/grpcserver/protowire"

"github.com/pkg/errors"
"google.golang.org/protobuf/encoding/protojson"

Expand Down Expand Up @@ -67,7 +68,7 @@ func postCommand(cfg *configFlags, client *grpcclient.GRPCClient, responseChan c
if err != nil {
printErrorAndExit(fmt.Sprintf("error posting the request to the RPC server: %s", err))
}
responseBytes, err := protojson.Marshal(response)
responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response)
if err != nil {
printErrorAndExit(errors.Wrapf(err, "error parsing the response from the RPC server").Error())
}
Expand All @@ -92,6 +93,7 @@ func prettifyResponse(response string) string {

marshalOptions := &protojson.MarshalOptions{}
marshalOptions.Indent = " "
marshalOptions.EmitUnpopulated = true
return marshalOptions.Format(kaspadMessage)
}

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/network/rpcclient/grpcclient/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c *GRPCClient) PostJSON(requestJSON string) (string, error) {
if err != nil {
return "", err
}
responseBytes, err := protojson.Marshal(response)
responseBytes, err := protojson.MarshalOptions{EmitUnpopulated: true}.Marshal(response)
if err != nil {
return "", errors.Wrapf(err, "error parsing the response from the RPC server")
}
Expand Down

0 comments on commit df19bdf

Please sign in to comment.