diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index 301cb43204..0c1e70696e 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -3,6 +3,7 @@ package autocli import ( "context" "fmt" + "strings" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "github.com/cosmos/cosmos-sdk/client/flags" @@ -157,6 +158,6 @@ func (b *Builder) outOrStdoutFormat(cmd *cobra.Command, out []byte) error { } } - _, err = fmt.Fprintln(cmd.OutOrStdout(), string(out)) - return err + cmd.Println(strings.TrimSpace(string(out))) + return nil } diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index 3fd10ea525..4b64ac02a2 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -124,8 +124,7 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript return err } - err = b.outOrStdoutFormat(cmd, bz) - return err + return b.outOrStdoutFormat(cmd, bz) }) if err != nil { return nil, err diff --git a/tools/hubl/internal/remote.go b/tools/hubl/internal/remote.go index 0f4ef0684f..34c7ae83e3 100644 --- a/tools/hubl/internal/remote.go +++ b/tools/hubl/internal/remote.go @@ -13,6 +13,7 @@ import ( "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/dynamicpb" + "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "cosmossdk.io/client/v2/autocli" @@ -108,6 +109,7 @@ func RemoteCommand(config *Config, configDir string) ([]*cobra.Command, error) { update bool reconfig bool insecure bool + output string ) chainCmd := &cobra.Command{ @@ -128,6 +130,7 @@ func RemoteCommand(config *Config, configDir string) ([]*cobra.Command, error) { chainCmd.Flags().BoolVar(&update, flagUpdate, false, "update the CLI commands for the selected chain (should be used after every chain upgrade)") chainCmd.Flags().BoolVar(&reconfig, flagConfig, false, "re-configure the selected chain (allows choosing a new gRPC endpoint and refreshes data") chainCmd.Flags().BoolVar(&insecure, flagInsecure, false, "allow re-configuring the selected chain using an insecure gRPC connection") + chainCmd.PersistentFlags().StringVar(&output, flags.FlagOutput, flags.OutputFormatJSON, "output format (text|json)") if err := appOpts.EnhanceRootCommandWithBuilder(chainCmd, builder); err != nil { return nil, err