diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b591633a04..f53879536ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * Renamed `MarshalAny` and `UnmarshalAny` to `MarshalInterface` and `UnmarshalInterface` respectively. These functions must take an interface as parameter (not a concrete type nor `Any` object). Underneath they use `Any` wrapping for correct protobuf serialization. * CLI: removed `--text` flag from `show-node-id` command; the text format for public keys is not used any more - instead we use ProtoJSON. * (types) [\#9079](https://github.com/cosmos/cosmos-sdk/issues/9079) Add `AddAmount`/`SubAmount` methods to `sdk.Coin`. +* [\#8628](https://github.com/cosmos/cosmos-sdk/issues/8628) Commands no longer print outputs using `stderr` by default ### API Breaking Changes diff --git a/client/flags/flags.go b/client/flags/flags.go index 1a0e5ad861d..fa13642127f 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -89,9 +89,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()) } // AddTxFlagsToCmd adds common flags to a module tx command. @@ -120,9 +117,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()) } // AddPaginationFlagsToCmd adds common pagination flags to cmd diff --git a/client/keys/add.go b/client/keys/add.go index 4176da632dd..7c337bab40d 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -79,9 +79,6 @@ Example: f.Uint32(flagIndex, 0, "Address index number for HD derivation") f.String(flags.FlagKeyAlgorithm, string(hd.Secp256k1Type), "Key signing algorithm to generate keys for") - cmd.SetOut(cmd.OutOrStdout()) - cmd.SetErr(cmd.ErrOrStderr()) - return cmd } diff --git a/client/keys/list.go b/client/keys/list.go index d6c2511b648..9aae471db52 100644 --- a/client/keys/list.go +++ b/client/keys/list.go @@ -33,8 +33,6 @@ func runListCmd(cmd *cobra.Command, _ []string) error { return err } - cmd.SetOut(cmd.OutOrStdout()) - if ok, _ := cmd.Flags().GetBool(flagListNames); !ok { printInfos(cmd.OutOrStdout(), infos, clientCtx.OutputFormat) return nil diff --git a/client/keys/migrate.go b/client/keys/migrate.go index 4816381e8c6..321750d9e87 100644 --- a/client/keys/migrate.go +++ b/client/keys/migrate.go @@ -89,7 +89,7 @@ func runMigrateCmd(cmd *cobra.Command, args []string) error { } if len(oldKeys) == 0 { - cmd.Print("Migration Aborted: no keys to migrate") + cmd.PrintErrln("Migration Aborted: no keys to migrate") return nil } diff --git a/server/export.go b/server/export.go index 8fd618028ba..150add98e78 100644 --- a/server/export.go +++ b/server/export.go @@ -109,8 +109,7 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com return nil }, } - cmd.SetOut(cmd.OutOrStdout()) - cmd.SetErr(cmd.ErrOrStderr()) + 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)") diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index ebb69b47c54..2e615eb87f0 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -53,6 +53,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()) + initClientCtx = client.ReadHomeFlag(initClientCtx, cmd) initClientCtx, err := config.ReadFromClientConfig(initClientCtx) diff --git a/version/command.go b/version/command.go index bb632aea5b1..9291c0a8249 100644 --- a/version/command.go +++ b/version/command.go @@ -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) diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index 1b887d1a059..3e8c0599faa 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -140,7 +140,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 } diff --git a/x/auth/client/cli/validate_sigs.go b/x/auth/client/cli/validate_sigs.go index d8d6283a799..03acf833f13 100644 --- a/x/auth/client/cli/validate_sigs.go +++ b/x/auth/client/cli/validate_sigs.go @@ -101,7 +101,7 @@ func printAndValidateSigs( if !offline && success { accNum, accSeq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, sigAddr) if err != nil { - cmd.Printf("failed to get account: %s\n", sigAddr) + cmd.PrintErrf("failed to get account: %s\n", sigAddr) return false } diff --git a/x/authz/types/generic_authorization_test.go b/x/authz/types/generic_authorization_test.go index e3330d1c659..2dda401c693 100644 --- a/x/authz/types/generic_authorization_test.go +++ b/x/authz/types/generic_authorization_test.go @@ -3,9 +3,10 @@ package types_test import ( "testing" + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/x/authz/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/stretchr/testify/require" ) func TestGenericAuthorization(t *testing.T) { diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 055a0b1fb0a..45bb718cd84 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -3,11 +3,12 @@ package types_test import ( "testing" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/stretchr/testify/require" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) var ( diff --git a/x/feegrant/types/filtered_fee.go b/x/feegrant/types/filtered_fee.go index 99cf5f1731a..ae34a687ff6 100644 --- a/x/feegrant/types/filtered_fee.go +++ b/x/feegrant/types/filtered_fee.go @@ -3,10 +3,11 @@ package types import ( "time" + proto "github.com/gogo/protobuf/proto" + "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - proto "github.com/gogo/protobuf/proto" ) // TODO: Revisit this once we have propoer gas fee framework.