Skip to content

Commit

Permalink
fix: output-document flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jan 8, 2024
1 parent bc89c06 commit 991be5e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
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
}
23 changes: 6 additions & 17 deletions x/auth/client/cli/tx_multisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +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().String(flags.FlagChainID, "", "network chain ID")
_ = cmd.Flags().MarkHidden(flags.FlagOutput)

return cmd
}
Expand Down Expand Up @@ -186,27 +186,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 @@ -240,6 +228,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 @@ -212,6 +212,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o
cmd.Flags().String(flags.FlagChainID, "", "The network chain ID")
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 991be5e

Please sign in to comment.