Skip to content

Commit

Permalink
use print proto instead of manually defining prints
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jul 15, 2024
1 parent 660aa8d commit 3dc6775
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions server/module_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package server

import (
"encoding/hex"
"encoding/json"
"fmt"
"sort"
"strconv"
Expand All @@ -13,6 +12,7 @@ import (
"cosmossdk.io/store/rootmulti"
storetypes "cosmossdk.io/store/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -41,29 +41,12 @@ func ModuleHashByHeightQuery[T servertypes.Application](appCreator servertypes.A
return err
}

outputFormat, err := cmd.Flags().GetString(flags.FlagOutput)
if err != nil {
return err
}

switch outputFormat {
case flags.OutputFormatJSON:
jsonOutput, err := json.MarshalIndent(commitInfoForHeight, "", " ")
if err != nil {
return err
}
cmd.Println(string(jsonOutput))
case flags.OutputFormatText:
fallthrough
default:
cmd.Println(commitInfoForHeight.String())
}

return nil
clientCtx := client.GetClientContextFromCmd(cmd)
return clientCtx.PrintProto(commitInfoForHeight)
},
}

cmd.Flags().StringP(flags.FlagOutput, "o", flags.OutputFormatText, "Output format (text|json)")
flags.AddQueryFlagsToCmd(cmd)

return cmd
}
Expand Down

0 comments on commit 3dc6775

Please sign in to comment.