Set proper default command output (#8628)
* Set proper default command output * Removed duplicated cmd.SetErr(cmd.ErrOrStderr()) and cmd.SetOut(cmd.OutOrStdout()) * Moved command initialization and added CHANGELOG * fix: groom all uses of cmd.Print* * Ran make format Co-authored-by: Michael FIG <mfig@agoric.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
This commit is contained in:
parent
b4fc48ca71
commit
96fe999343
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue