Skip to content

Commit

Permalink
Merge pull request #145 from dai1975/features/lo4326-output-json-marshal
Browse files Browse the repository at this point in the history
use gogoprogo.jsobpb.Marshaler to output object
  • Loading branch information
siburu authored Aug 12, 2024
2 parents cfa3a29 + 6d54839 commit a10aff4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hyperledger-labs/yui-relayer/core"
"github.com/hyperledger-labs/yui-relayer/helpers"
"github.com/spf13/cobra"
"github.com/cosmos/gogoproto/jsonpb"
)

// queryCmd represents the chain command
Expand Down Expand Up @@ -66,7 +67,12 @@ func queryClientCmd(ctx *config.Context) *cobra.Command {
if err := c.Codec().UnpackAny(res.ClientState, &cs); err != nil {
return err
}
fmt.Println(cs)
marshaler := jsonpb.Marshaler{}
if json, err := marshaler.MarshalToString(cs); err != nil {
fmt.Println(cs.String())
} else {
fmt.Println(json)
}
return nil
},
}
Expand Down Expand Up @@ -99,7 +105,12 @@ func queryConnection(ctx *config.Context) *cobra.Command {
if err != nil {
return err
}
fmt.Println(res.Connection.String())
marshaler := jsonpb.Marshaler{}
if json, err := marshaler.MarshalToString(res.Connection); err != nil {
fmt.Println(res.Connection.String())
} else {
fmt.Println(json)
}
return nil
},
}
Expand Down Expand Up @@ -132,7 +143,12 @@ func queryChannel(ctx *config.Context) *cobra.Command {
if err != nil {
return err
}
fmt.Println(res.Channel.String())
marshaler := jsonpb.Marshaler{}
if json, err := marshaler.MarshalToString(res.Channel); err != nil {
fmt.Println(res.Channel.String())
} else {
fmt.Println(json)
}
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion tests/docker.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DOCKER ?= docker
DOCKER_COMPOSE ?= docker-compose
DOCKER_COMPOSE ?= docker compose
DOCKER_REPO ?= ""
DOCKER_TAG ?= latest
DOCKER_BUILD ?= $(DOCKER) build --rm --no-cache --pull
Expand Down

0 comments on commit a10aff4

Please sign in to comment.