Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set proper default command output #8628

Merged
merged 13 commits into from
Apr 17, 2021
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Client Breaking Changes

* [\#8363](https://github.com/cosmos/cosmos-sdk/issues/8363) Addresses no longer have a fixed 20-byte length. From the SDK modules' point of view, any 1-255 bytes-long byte array is a valid address.
* [\#8628](https://github.com/cosmos/cosmos-sdk/issues/8628) Commands no longer print outputs using `stderr` by default

### API Breaking Changes

Expand Down
6 changes: 0 additions & 6 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")

cmd.MarkFlagRequired(FlagChainID)

cmd.SetErr(cmd.ErrOrStderr())
cmd.SetOut(cmd.OutOrStdout())
alessio marked this conversation as resolved.
Show resolved Hide resolved
}

// AddTxFlagsToCmd adds common flags to a module tx command.
Expand Down Expand Up @@ -119,9 +116,6 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
cmd.Flags().String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically (default %d)", GasFlagAuto, DefaultGasLimit))

cmd.MarkFlagRequired(FlagChainID)

cmd.SetErr(cmd.ErrOrStderr())
cmd.SetOut(cmd.OutOrStdout())
alessio marked this conversation as resolved.
Show resolved Hide resolved
}

// AddPaginationFlagsToCmd adds common pagination flags to cmd
Expand Down
3 changes: 0 additions & 3 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ the flag --nosort is set.
cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation")
cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for")

cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

alessio marked this conversation as resolved.
Show resolved Hide resolved
return cmd
}

Expand Down
2 changes: 0 additions & 2 deletions client/keys/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ func runListCmd(cmd *cobra.Command, _ []string) error {
return err
}

cmd.SetOut(cmd.OutOrStdout())

alessio marked this conversation as resolved.
Show resolved Hide resolved
if ok, _ := cmd.Flags().GetBool(flagListNames); !ok {
output, _ := cmd.Flags().GetString(cli.OutputFlag)
printInfos(cmd.OutOrStdout(), infos, output)
Expand Down
3 changes: 1 addition & 2 deletions server/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com
return nil
},
}
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

alessio marked this conversation as resolved.
Show resolved Hide resolved
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
cmd.Flags().Int64(FlagHeight, -1, "Export state from a particular height (-1 means latest height)")
cmd.Flags().Bool(FlagForZeroHeight, false, "Export state to start at height zero (perform preproccessing)")
Expand Down
4 changes: 4 additions & 0 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
Use: "simd",
Short: "simulation app",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())

if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func NewVersionCommand() *cobra.Command {
Short: "Print the application binary version information",
RunE: func(cmd *cobra.Command, _ []string) error {
verInfo := NewInfo()
cmd.SetOut(cmd.OutOrStdout())

if long, _ := cmd.Flags().GetBool(flagLong); !long {
cmd.Println(verInfo.Version)
Expand Down
1 change: 0 additions & 1 deletion x/auth/client/cli/tx_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
func setOutputFile(cmd *cobra.Command) (func(), error) {
outputDoc, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
if outputDoc == "" {
cmd.SetOut(cmd.OutOrStdout())
return func() {}, nil
}

Expand Down