From 56d46c9a26a8f10447b0e247b16140bde8590270 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Sun, 18 Jul 2021 21:20:17 +0530 Subject: [PATCH 1/3] feat: added --output flag to all tx cli commands --- client/context.go | 5 +++++ client/flags/flags.go | 1 + 2 files changed, 6 insertions(+) diff --git a/client/context.go b/client/context.go index 1308823c8409..d9240a3b1571 100644 --- a/client/context.go +++ b/client/context.go @@ -240,6 +240,11 @@ func (ctx Context) PrintString(str string) error { return ctx.PrintBytes([]byte(str)) } +// PrintOutput print the raw bytes to ctx.Output if it's defined , otherwise to os.Stdout +func (ctx Context) PrintOutput(o []byte) error { + return ctx.printOutput(o) +} + // PrintBytes prints the raw bytes to ctx.Output if it's defined, otherwise to os.Stdout. // NOTE: for printing a complex state object, you should use ctx.PrintOutput func (ctx Context) PrintBytes(o []byte) error { diff --git a/client/flags/flags.go b/client/flags/flags.go index 80c3e792256a..c4faad1b035a 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -93,6 +93,7 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { // AddTxFlagsToCmd adds common flags to a module tx command. func AddTxFlagsToCmd(cmd *cobra.Command) { + cmd.Flags().StringP(tmcli.OutputFlag, "o", "json", "Output format (text|json)") cmd.Flags().String(FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") cmd.Flags().String(FlagFrom, "", "Name or address of private key with which to sign") cmd.Flags().Uint64P(FlagAccountNumber, "a", 0, "The account number of the signing account (offline mode only)") From 5150d0d91faea1a710b81bc458a03c599d1560b5 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Sun, 18 Jul 2021 21:32:59 +0530 Subject: [PATCH 2/3] removed PrintOutput func --- client/context.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/context.go b/client/context.go index d9240a3b1571..1308823c8409 100644 --- a/client/context.go +++ b/client/context.go @@ -240,11 +240,6 @@ func (ctx Context) PrintString(str string) error { return ctx.PrintBytes([]byte(str)) } -// PrintOutput print the raw bytes to ctx.Output if it's defined , otherwise to os.Stdout -func (ctx Context) PrintOutput(o []byte) error { - return ctx.printOutput(o) -} - // PrintBytes prints the raw bytes to ctx.Output if it's defined, otherwise to os.Stdout. // NOTE: for printing a complex state object, you should use ctx.PrintOutput func (ctx Context) PrintBytes(o []byte) error { From fbb344c66449569360f6bf5b079adc2acc08af5b Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Thu, 22 Jul 2021 18:47:42 +0530 Subject: [PATCH 3/3] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a7ba61fcbd1..06a4b199acfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (cli) [\#9593](https://github.com/cosmos/cosmos-sdk/pull/9593) Check if chain-id is blank before verifying signatures in multisign and error. +* (cli) [\#9717](https://github.com/cosmos/cosmos-sdk/pull/9717) Added CLI flag `--output json/text` to `tx` cli commands. ### Bug Fixes