Skip to content

Commit

Permalink
refactor: hide --output flags that don't work (backport #17188) (#1…
Browse files Browse the repository at this point in the history
…7192)

Co-authored-by: zakir-code <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2023
1 parent eeee766 commit 1a2ad4f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Bug Fixes

* (cli) [#17188](https://github.com/cosmos/cosmos-sdk/pull/17188) Fix `--output-document` flag in `tx multi-sign`.

## [v0.47.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.4) - 2023-07-17

### Features
Expand Down
1 change: 1 addition & 0 deletions x/auth/client/cli/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func GetDecodeCommand() *cobra.Command {

cmd.Flags().BoolP(flagHex, "x", false, "Treat input as hexadecimal instead of base64")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // decoding makes sense to output only json

return cmd
}
1 change: 1 addition & 0 deletions x/auth/client/cli/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ If you supply a dash (-) argument in place of an input filename, the command rea
}

flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // encoding makes sense to output only json

return cmd
}
22 changes: 6 additions & 16 deletions x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The SIGN_MODE_DIRECT sign mode is not supported.'
cmd.Flags().String(flags.FlagOutputDocument, "", "The document is written to the given file instead of STDOUT")
cmd.Flags().Bool(flagAmino, false, "Generate Amino-encoded JSON suitable for submitting to the txs REST endpoint")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput)

return cmd
}
Expand Down Expand Up @@ -188,27 +189,15 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) {
}
}

outputDoc, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
if outputDoc == "" {
cmd.Printf("%s\n", json)
return
}

fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644)
closeFunc, err := setOutputFile(cmd)
if err != nil {
return err
}

defer func() {
err2 := fp.Close()
if err == nil {
err = err2
}
}()

err = clientCtx.PrintBytes(json)
defer closeFunc()

return
cmd.Printf("%s\n", json)
return nil
}
}

Expand Down Expand Up @@ -243,6 +232,7 @@ The SIGN_MODE_DIRECT sign mode is not supported.'
)
cmd.Flags().String(flags.FlagOutputDocument, "", "The document is written to the given file instead of STDOUT")
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // signing makes sense to output only json

return cmd
}
Expand Down
1 change: 1 addition & 0 deletions x/genutil/client/cli/gentx.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o
cmd.Flags().String(flags.FlagOutputDocument, "", "Write the genesis transaction JSON document to the given file instead of the default location")
cmd.Flags().AddFlagSet(fsCreateValidator)
flags.AddTxFlagsToCmd(cmd)
_ = cmd.Flags().MarkHidden(flags.FlagOutput) // signing makes sense to output only json

return cmd
}
Expand Down

0 comments on commit 1a2ad4f

Please sign in to comment.