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
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
6 changes: 6 additions & 0 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
a := appCreator{encodingConfig}
server.AddCommands(rootCmd, simapp.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags)

// set the default command output properly
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
cmd.SetOut(cmd.OutOrStdout())
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
cmd.SetErr(cmd.ErrOrStderr())
}

// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
rpc.StatusCommand(),
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