github.com/Finschia/finschia-sdk@v0.48.1/x/params/client/cli/query.go (about) 1 package cli 2 3 import ( 4 "github.com/spf13/cobra" 5 6 "github.com/Finschia/finschia-sdk/client" 7 "github.com/Finschia/finschia-sdk/client/flags" 8 "github.com/Finschia/finschia-sdk/x/params/types" 9 "github.com/Finschia/finschia-sdk/x/params/types/proposal" 10 ) 11 12 // NewQueryCmd returns a root CLI command handler for all x/params query commands. 13 func NewQueryCmd() *cobra.Command { 14 cmd := &cobra.Command{ 15 Use: types.ModuleName, 16 Short: "Querying commands for the params module", 17 DisableFlagParsing: true, 18 SuggestionsMinimumDistance: 2, 19 RunE: client.ValidateCmd, 20 } 21 22 cmd.AddCommand(NewQuerySubspaceParamsCmd()) 23 24 return cmd 25 } 26 27 // NewQuerySubspaceParamsCmd returns a CLI command handler for querying subspace 28 // parameters managed by the x/params module. 29 func NewQuerySubspaceParamsCmd() *cobra.Command { 30 cmd := &cobra.Command{ 31 Use: "subspace [subspace] [key]", 32 Short: "Query for raw parameters by subspace and key", 33 Args: cobra.ExactArgs(2), 34 RunE: func(cmd *cobra.Command, args []string) error { 35 clientCtx, err := client.GetClientQueryContext(cmd) 36 if err != nil { 37 return err 38 } 39 queryClient := proposal.NewQueryClient(clientCtx) 40 41 params := proposal.QueryParamsRequest{Subspace: args[0], Key: args[1]} 42 res, err := queryClient.Params(cmd.Context(), ¶ms) 43 if err != nil { 44 return err 45 } 46 47 return clientCtx.PrintProto(&res.Param) 48 }, 49 } 50 51 flags.AddQueryFlagsToCmd(cmd) 52 53 return cmd 54 }