From 5081c930de9897a19609838e2ae6db649cf8225d Mon Sep 17 00:00:00 2001 From: Frank Yang Date: Fri, 15 Mar 2019 23:08:05 +0800 Subject: [PATCH] Merge PR #3887: Add indent to prompt of `gaiacli tx send` * Add indent to prompt of `gaiacli tx send`. * Add indent to prompt of `gaiacli tx send` with flag --indent. --- client/utils/utils.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/utils/utils.go b/client/utils/utils.go index 8d1c0b4943..d924d92042 100644 --- a/client/utils/utils.go +++ b/client/utils/utils.go @@ -3,6 +3,7 @@ package utils import ( "bytes" "fmt" + "github.com/spf13/viper" "io/ioutil" "os" @@ -69,7 +70,16 @@ func CompleteAndBroadcastTxCLI(txBldr authtxb.TxBuilder, cliCtx context.CLIConte return err } - fmt.Fprintf(os.Stderr, "%s\n\n", cliCtx.Codec.MustMarshalJSON(stdSignMsg)) + var json []byte + if viper.GetBool(client.FlagIndentResponse) { + json, err = cliCtx.Codec.MarshalJSONIndent(stdSignMsg, "", " ") + if err != nil { + panic(err) + } + } else { + json = cliCtx.Codec.MustMarshalJSON(stdSignMsg) + } + fmt.Fprintf(os.Stderr, "%s\n\n", json) buf := client.BufferStdin() ok, err := client.GetConfirmation("confirm transaction before signing and broadcasting", buf)